本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting类的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.VisualStudio.TestTools.UnitTesting类的具体用法?C# Microsoft.VisualStudio.TestTools.UnitTesting怎么用?C# Microsoft.VisualStudio.TestTools.UnitTesting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Microsoft.VisualStudio.TestTools.UnitTesting类属于命名空间,在下文中一共展示了Microsoft.VisualStudio.TestTools.UnitTesting类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChannelPropertyReply
public void ChannelPropertyReply()
{
var raws = new[] {
":chat3 818 alfaproject #testing ONJOIN :Welcome to the stupidest channel ever.",
":chat3 818 alfaproject #testing GUID {}",
":chat3 818 alfaproject #testing CREATOR alfaproject[[email protected].safetypin.net]"
};
var channels = new[] {
"#testing",
"#testing",
"#testing"
};
var properties = new[] {
"ONJOIN",
"GUID",
"CREATOR"
};
var values = new[] {
"Welcome to the stupidest channel ever.",
"{}",
"alfaproject[[email protected]]"
};
for (var i = 0; i < raws.Length; i++)
{
var msg = MessageAssert.TypeAndRoundTrip<ChannelPropertyReplyMessage>(raws[i]);
Assert.AreEqual(channels[i], msg.Channel, "Channel");
Assert.AreEqual(properties[i], msg.Prop, "Property");
Assert.AreEqual(values[i], msg.Value, "New Value");
}
}
示例2: T_FromGame
public void T_FromGame()
{
// ####
// 0I23456789
var colums = new[] { 0, 0, 0, 1, 1, 1, 1, 0, 0, 0 };
var pointUpPositions = PiceT.PositionsPointUp(colums);
var pointDownPositions = PiceT.PositionsPointDown(colums);
var pointLeftPositions = PiceT.PositionsPointLeft(colums);
var pointRightPositions = PiceT.PositionsPointRight(colums);
Assert.AreEqual(4, pointUpPositions.Count);
Assert.AreEqual(0, pointDownPositions.Count);
Assert.AreEqual(1, pointLeftPositions.Count);
Assert.AreEqual(1, pointRightPositions.Count);
foreach (var u in pointUpPositions)
Assert.AreEqual(0, u.Rotation);
foreach (var d in pointDownPositions)
Assert.AreEqual(2, d.Rotation);
foreach (var l in pointLeftPositions)
Assert.AreEqual(3, l.Rotation);
foreach (var r in pointRightPositions)
Assert.AreEqual(1, r.Rotation);
Assert.AreEqual(0, pointUpPositions[0].X);
}
示例3: TestValidSources
public void TestValidSources()
{
// Arrange
string[] testValues = new[] { "http://bing.com", "http://microsoft.com", "https://paypal.com", "http://library" };
TestValues(testValues, true);
}
示例4: TvEpisodesWithSceneFileNameFormattingAreCorrectlyParsed
public void TvEpisodesWithSceneFileNameFormattingAreCorrectlyParsed()
{
//Arrange
var fileName = "The.Big.Bang.Theory.S04E03.The.Zazzy.Substitution.BluRay.1080p.Remux.AVC.DTS-HDMA.5.1-BluHD.mkv";
var expectedResults = new
{
FileName = "The.Big.Bang.Theory.S04E03.The.Zazzy.Substitution.BluRay.1080p.Remux.AVC.DTS-HDMA.5.1-BluHD.mkv",
ShowName = "The Big Bang Theory",
Extension = ".mkv",
Episode = "03",
EpisodeRange = "",
Season = "04"
};
//Act
var obj = new TvEpisode(fileName);
//Assert
Assert.AreEqual(expectedResults.FileName, obj.FileName);
Assert.AreEqual(expectedResults.ShowName, obj.Name);
Assert.AreEqual(expectedResults.Extension, obj.Extension);
Assert.AreEqual(expectedResults.Episode, obj.Episode);
Assert.AreEqual(expectedResults.EpisodeRange, obj.EpisodeRange);
Assert.AreEqual(expectedResults.Season, obj.Season);
}
示例5: TvEpisodesAlreadyInTargetFormattingAreCorrectlyParsed
public void TvEpisodesAlreadyInTargetFormattingAreCorrectlyParsed()
{
//Arrange
var fileName = "Doctor Who - S09E16.mkv";
var expectedResults = new
{
FileName = "Doctor Who - S09E16.mkv",
ShowName = "Doctor Who",
Extension = ".mkv",
Episode = "16",
EpisodeRange = "",
Season = "09"
};
//Act
var obj = new TvEpisode(fileName);
//Assert
Assert.AreEqual(expectedResults.FileName, obj.FileName);
Assert.AreEqual(expectedResults.ShowName, obj.Name);
Assert.AreEqual(expectedResults.Extension, obj.Extension);
Assert.AreEqual(expectedResults.Episode, obj.Episode);
Assert.AreEqual(expectedResults.EpisodeRange, obj.EpisodeRange);
Assert.AreEqual(expectedResults.Season, obj.Season);
}
示例6: CatchEnumerable
public void CatchEnumerable()
{
{
var xs = new[]
{
Observable.Return(2).Concat(Observable.Throw<int>(new Exception())),
Observable.Return(99).Concat(Observable.Throw<int>(new Exception())),
Observable.Range(10,2)
}
.Catch()
.Materialize()
.ToArrayWait();
xs[0].Value.Is(2);
xs[1].Value.Is(99);
xs[2].Value.Is(10);
xs[3].Value.Is(11);
xs[4].Kind.Is(NotificationKind.OnCompleted);
}
{
var xs = new[]
{
Observable.Return(2).Concat(Observable.Throw<int>(new Exception())),
Observable.Return(99).Concat(Observable.Throw<int>(new Exception()))
}
.Catch()
.Materialize()
.ToArrayWait();
xs[0].Value.Is(2);
xs[1].Value.Is(99);
xs[2].Kind.Is(NotificationKind.OnError);
}
}
示例7: GetBlockingMoveTestMethod
public void GetBlockingMoveTestMethod()
{
var boards = new[] { new[] { -1, -1, 0, 0, 1, 1, 0, 0, 0 }, //
new[] { 0, 0, 1, -1, 1, 0, 0, 0, 0 } };
var positions = new[]
{
new[] { 2, 0 }, //
new[] { 0, 2 }, //
};
for (var i = 0; i < boards.Length; i++)
{
var board = boards[i];
var g = new CurrentGame(new Board(board));
var brainResult = new BrainResult();
var canMove = g.GetNewMove(brainResult);
try
{
Assert.AreEqual(positions[i][0], brainResult.Moves[0].X);
Assert.AreEqual(positions[i][1], brainResult.Moves[0].Y);
Assert.AreEqual(true, canMove);
}
catch
{
UnitTestHelpers.PrintBoard(board, brainResult.Moves[0].X, brainResult.Moves[0].Y, canMove);
throw;
}
}
}
示例8: SM_WithStringPropsAndSamePossibleStrings_ShouldBe_Satisfiable
public void SM_WithStringPropsAndSamePossibleStrings_ShouldBe_Satisfiable()
{
// Arrange
var objectTheorem = new ObjectTheoremContext();
var stringNames = new[] { "Hans", "Fred", "Max" };
objectTheorem.SetPossibleStringValues(stringNames);
var classWithStringA = objectTheorem.CreateInstance<ClassWithStringA>("ClassWithStringA");
var classWithStringB = objectTheorem.CreateInstance<ClassWithStringB>("ClassWithStringB");
// Act
objectTheorem.ConstraintBuilder
.AssertAll<ClassWithStringA, ClassWithStringB>((a, b) => a.FirstName == b.LastName)
.Assert(() => "Hans" == classWithStringA.FirstName);
// Assert
var solved = objectTheorem.Solve();
Assert.IsNotNull(solved);
string firstName = solved.GetValue(classWithStringA, i => i.FirstName);
string lastName = solved.GetValue(classWithStringB, i => i.LastName);
Assert.AreEqual("Hans", firstName);
Assert.AreEqual("Hans", lastName);
}
示例9: Watch602Test
public void Watch602Test()
{
var raws = new[] {
":hotspeed.sg.as.dal.net 602 _aLfa_ alfa * * 0 :stopped watching",
":hotspeed.sg.as.dal.net 602 _aLfa_ _aLfa_ _aLfa_ c-24-8-243-76.client.comcast.net 1082383544 :stopped watching",
":hotspeed.sg.as.dal.net 602 _aLfa_ _aLfa_ _aLfa_ c-24-8-243-76.client.comcast.net 1082383572 :stopped watching"
};
var msg = MessageAssert.TypeAndRoundTrip<WatchStoppedMessage>(raws[0]);
Assert.AreEqual(msg.WatchedUser.Nickname, "alfa");
Assert.AreEqual(msg.WatchedUser.Username, "*");
Assert.AreEqual(msg.WatchedUser.Host, "*");
Assert.AreEqual(MessageUtil.ConvertToUnixTime(msg.TimeOfChange), 0);
msg = MessageAssert.TypeAndRoundTrip<WatchStoppedMessage>(raws[1]);
Assert.AreEqual(msg.WatchedUser.Nickname, "_aLfa_");
Assert.AreEqual(msg.WatchedUser.Username, "_aLfa_");
Assert.AreEqual(msg.WatchedUser.Host, "c-24-8-243-76.client.comcast.net");
Assert.AreEqual(MessageUtil.ConvertToUnixTime(msg.TimeOfChange), 1082383544);
msg = MessageAssert.TypeAndRoundTrip<WatchStoppedMessage>(raws[2]);
Assert.AreEqual(msg.WatchedUser.Nickname, "_aLfa_");
Assert.AreEqual(msg.WatchedUser.Username, "_aLfa_");
Assert.AreEqual(msg.WatchedUser.Host, "c-24-8-243-76.client.comcast.net");
Assert.AreEqual(MessageUtil.ConvertToUnixTime(msg.TimeOfChange), 1082383572);
}
示例10: CreateFromConfigTest
public void CreateFromConfigTest()
{
var testData = new[]
{
new { Type = "ByteOutput", Reg = 0},
new { Type = "WordOutput", Reg = 1},
new { Type = "ByteOutput", Reg = 2},
new { Type = "FloatOutput", Reg = 4},
new { Type = "DWordOutput", Reg = 6}
};
var entries = testData
.Select((a, i) => new ConfigEntry()
{
Name = "regVarAt" + a.Reg, TypeName = a.Type
})
.ToArray();
var outs = AbstractOutput.CreateFromConfig(entries, n => { }).ToArray();
Assert.AreEqual(entries.Length, outs.Length);
for (int i = 0; i < testData.Length; i++)
{
Assert.AreEqual(outs[i].RegOffset, testData[i].Reg);
}
}
示例11: FilePathMatcherTest
public void FilePathMatcherTest()
{
string[] testFiles = new [] {"c:/temp/subfolder/file.js",
"c:/temp/file.cs",
"c:/projects/temp/file.cs",
"c:/projects/file.js",
"c:/projects/file.min.js"};
List<string> matches = new List<string>(FilePathMatcher.MatchFiles("*.js",testFiles,false));
List<string> expected = new List<string>(new[] {"c:/temp/subfolder/file.js", "c:/projects/file.js",
"c:/projects/file.min.js"});
Assert.AreEqual(3,matches.Count,"Matches single extension pattern *.js");
Assert.AreEqual(string.Join(",", expected),string.Join(",",matches),"List matches");
matches = new List<string>(FilePathMatcher.MatchFiles("*.min.js",testFiles,true));
Assert.AreEqual(4,matches.Count,"Matches exclusion pattern *.min.js");
matches = new List<string>(FilePathMatcher.MatchFiles("temp/",testFiles,true));
expected = new List<string>(new[] {"c:/projects/file.js",
"c:/projects/file.min.js"});
Assert.AreEqual(string.Join(",",expected),string.Join(",",matches),"List matches on excluding a folder path");
}
示例12: SortByGivenOrderTest
public void SortByGivenOrderTest()
{
var id1 = Guid.NewGuid();
var id2 = Guid.NewGuid();
var id3 = Guid.NewGuid();
var id4 = Guid.NewGuid();
var expectedOrder = new Guid?[] { id1, id2, id3, id4 };
var items = new[]
{
new SomeEntity { Name = "a", Reference = id3 },
new SomeEntity { Name = "b", Reference = id2 },
new SomeEntity { Name = "c", Reference = id1 },
new SomeEntity { Name = "d", Reference = id2 },
new SomeEntity { Name = "e", Reference = id4 }
};
Graph.SortByGivenOrder(items, expectedOrder, item => item.Reference);
string result = string.Join(", ", items.Select(item => item.Name));
const string expectedResult1 = "c, b, d, a, e";
const string expectedResult2 = "c, d, b, a, e";
Console.WriteLine("result: " + result);
Console.WriteLine("expectedResult1: " + expectedResult1);
Console.WriteLine("expectedResult2: " + expectedResult2);
Assert.IsTrue(result == expectedResult1 || result == expectedResult2, "Result '" + result + "' is not '" + expectedResult1 + "' nor '" + expectedResult2 + "'.");
}
示例13: TestMobileListConvert
public void TestMobileListConvert()
{
string expect = "1,2,3";
var mobiles = new[] { "1", "2", "3" };
var result = string.Join(",", mobiles);
Assert.AreEqual(expect, result);
}
示例14: I_DeepHole
public void I_DeepHole()
{
// ##### # ##
// ##### ####
// ##########
// 0I23456789
var colums = new[] { 3, 3, 3, 3, 3, 1, 3, 2, 3, 3 };
var deepHolePositions = PiceI.PositionsDeepHole(colums);
var oneLevelPositions = PiceI.PositionsOneLevelStep(colums);
var flatPositions = PiceI.PositionsFlat(colums);
Assert.AreEqual(1, deepHolePositions.Count);
Assert.AreEqual(2, oneLevelPositions.Count);
Assert.AreEqual(2, flatPositions.Count);
foreach (var d in deepHolePositions)
Assert.AreEqual(1, d.Rotation);
foreach (var o in oneLevelPositions)
Assert.AreEqual(1, o.Rotation);
foreach (var f in flatPositions)
Assert.AreEqual(0, f.Rotation);
Assert.AreEqual(5, deepHolePositions[0].X);
}
示例15: EsfTokenNameToByte_SuccessfullyConvertsTokenNames
public void EsfTokenNameToByte_SuccessfullyConvertsTokenNames()
{
var tokens = new
{
UINT16 = new { Value = 0x01, Name = "uint16" },
INT16 = new { Value = 0x02, Name = "int16" },
UINT32 = new { Value = 0x03, Name = "uint32" },
INT32 = new { Value = 0x04, Name = "int32" },
STRING = new { Value = 0x05, Name = "string" },
IPADDR = new { Value = 0x06, Name = "ip_addr" },
INT64 = new { Value = 0x07, Name = "int64" },
UINT64 = new { Value = 0x08, Name = "uint64" },
BOOLEAN = new { Value = 0x09, Name = "boolean" }
};
Assert.AreEqual(tokens.UINT16.Value, EsfParser.TokenNameToByte(tokens.UINT16.Name));
Assert.AreEqual(tokens.INT16.Value, EsfParser.TokenNameToByte(tokens.INT16.Name));
Assert.AreEqual(tokens.UINT32.Value, EsfParser.TokenNameToByte(tokens.UINT32.Name));
Assert.AreEqual(tokens.INT32.Value, EsfParser.TokenNameToByte(tokens.INT32.Name));
Assert.AreEqual(tokens.STRING.Value, EsfParser.TokenNameToByte(tokens.STRING.Name));
Assert.AreEqual(tokens.IPADDR.Value, EsfParser.TokenNameToByte(tokens.IPADDR.Name));
Assert.AreEqual(tokens.INT64.Value, EsfParser.TokenNameToByte(tokens.INT64.Name));
Assert.AreEqual(tokens.UINT64.Value, EsfParser.TokenNameToByte(tokens.UINT64.Name));
Assert.AreEqual(tokens.BOOLEAN.Value, EsfParser.TokenNameToByte(tokens.BOOLEAN.Name));
}