diff --git a/UseXUint.sln b/UseXUint.sln index 35b9a60..9339912 100644 --- a/UseXUint.sln +++ b/UseXUint.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2042 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetFramework20", "DotNetFramework20\DotNetFramework20.csproj", "{E88F4843-6F11-497A-8D61-F28F1FF1109F}" EndProject @@ -37,6 +37,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "说明", "说明", "{E5C526 ProjectSection(SolutionItems) = preProject ..\xUnit版本支持说明.png = ..\xUnit版本支持说明.png ..\xUnit版本支持说明.xlsx = ..\xUnit版本支持说明.xlsx + 说明.md = 说明.md EndProjectSection EndProject Global diff --git a/说明.md b/说明.md new file mode 100644 index 0000000..c94aa6b --- /dev/null +++ b/说明.md @@ -0,0 +1,77 @@ +˵ +============ +## ԣ쳣 + +߰汾ȡ Assert.NotThrow() ԣʹö "ϲ쳣" Ƚѡ + ++ ʹ xUnit Դ Record ͨʵ + ```csharp + //ִд + Action codeSnippet = () => + { + //ҵ + + //ģ쳣 + //throw new Exception("׳쳣"); + }; + + var exception = Record.Exception(codeSnippet); + Assert.Null(exception); + ``` ++ ʹ FluentAssertions + ```csharp + //ִд + Action codeSnippet= () => + { + //ҵ + + //ģ쳣 + //throw new Exception("׳쳣"); + }; + + //ԣ쳣 + codeSnippet.Should().NotThrow(); + ``` + +## ԣִ(ִйһε) +ĿǰûҵԷִĶ( ִй ִֻһ ִһ),һЩͨ + ++ ʹ Moq ⣬ֻ"ģ",ֻ鷽ӿڷ + ```csharp + public class Person + { + public string Name { get; set; } + public int Id { get; set; } + + /// + /// 鷽ӿ + /// + public virtual void DoSomething() + { + Console.WriteLine("Ƿ"); + } + } + + using Moq; + namespace WatchStudy.CancellationTokenStudy + { + public class UnitTest1 + { + //Է + [Fact] + public void Test1() + { + //ģⷽ + var mock = new Mock(); + mock.Setup(foo => foo.DoSomething()); + + //÷һ + mock.Object.DoSomething(); + + // DoSomething ִһ + mock.Verify(foo => foo.DoSomething(), Times.Once()); + } + } + } + + ```