diff --git a/.gitignore b/.gitignore index 842317924..7effe32b9 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ LibGit2Sharp/Core/UniqueIdentifier.cs !Lib/NativeBinaries/*/*.pdb !nuget.package/build/ _NCrunch_LibGit2Sharp/ +packages/ diff --git a/.nuget/packages.config b/.nuget/packages.config new file mode 100644 index 000000000..05ac50048 --- /dev/null +++ b/.nuget/packages.config @@ -0,0 +1,4 @@ + + + + diff --git a/.travis.yml b/.travis.yml index 95c960799..5ab00c105 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ install: ./CI/travis.${TRAVIS_OS_NAME}.install.deps.sh # Build libgit2, LibGit2Sharp and run the tests script: - - ./build.libgit2sharp.sh + - ./build.libgit2sharp.sh 'LEAKS_IDENTIFYING' # Only watch the development branch branches: diff --git a/CHANGES.md b/CHANGES.md index eeda7b55d..d0625fec6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,8 +7,32 @@ - Issue tracker: - @libgit2sharp: - CI servers: - - CodeBetter TeamCity: - - Travis: + - Windows (x86/amd64): + - Linux/MacOsX: + +## v0.21 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.20.2...v0.21)) + +### Additions + + - Introduce repo.Index.Add() and repo.Index.Remove() (#907) + - Introduce repo.Describe() (#848) + - Teach Repository.Clone to accept a specific branch to checkout (#650, #882) + - Expose IndexEntry.AssumeUnchanged (#928, #929) + - Introduce GlobalSettings.Version.InformationalVersion (#921) + +### Changes + + - Deprecate Branch.Checkout() (#937) + - Deprecate GlobalSettings.Version.MajorMinorPatch (#921) + - Change Blob.Size output to a long (#892) + - Update libgit2 binaries to libgit2/libgit2@e0902fb + +### Fixes + + - Fix Network.Fetch() tags retrieval (#927) + - Fix repo.Stage("*") behavior (#907) + - Plug some memory leaks (#883, #910) + - Protect Repository.Clone() from null parameters (#891) ## v0.20.2 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.20.1...v0.20.2)) diff --git a/CI/build.msbuild b/CI/build.msbuild index 5a94395e7..f7bb2ee6a 100644 --- a/CI/build.msbuild +++ b/CI/build.msbuild @@ -6,17 +6,17 @@ $(RootDir)\Build - - + - + - + @@ -29,10 +29,11 @@ + + Properties="Configuration=$(Configuration);TrackFileAccess=false;ExtraDefine=$(ExtraDefine)" /> @@ -40,15 +41,17 @@ - - - + + + + - - - + + + + diff --git a/Lib/MoQ/Moq.dll b/Lib/MoQ/Moq.dll deleted file mode 100644 index bdd4235f2..000000000 Binary files a/Lib/MoQ/Moq.dll and /dev/null differ diff --git a/Lib/MoQ/Moq.license.txt b/Lib/MoQ/Moq.license.txt deleted file mode 100644 index c9216ccba..000000000 --- a/Lib/MoQ/Moq.license.txt +++ /dev/null @@ -1,39 +0,0 @@ -Copyright (c) 2007. Clarius Consulting, Manas Technology Solutions, InSTEDD -http://code.google.com/p/moq/ -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - - * Redistributions of source code must retain the - above copyright notice, this list of conditions and - the following disclaimer. - - * Redistributions in binary form must reproduce - the above copyright notice, this list of conditions - and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of Clarius Consulting, Manas Technology Solutions or InSTEDD nor the - names of its contributors may be used to endorse - or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. - -[This is the BSD license, see - http://www.opensource.org/licenses/bsd-license.php] diff --git a/Lib/MoQ/Moq.xml b/Lib/MoQ/Moq.xml deleted file mode 100644 index 160c1b516..000000000 --- a/Lib/MoQ/Moq.xml +++ /dev/null @@ -1,5449 +0,0 @@ - - - - Moq - - - - - Implements the fluent API. - - - - - The expectation will be considered only in the former condition. - - - - - - - The expectation will be considered only in the former condition. - - - - - - - - Setups the get. - - The type of the property. - The expression. - - - - - Setups the set. - - The type of the property. - The setter expression. - - - - - Setups the set. - - The setter expression. - - - - - Handle interception - - the current invocation context - shared data for the interceptor as a whole - shared data among the strategies during a single interception - InterceptionAction.Continue if further interception has to be processed, otherwise InterceptionAction.Stop - - - - Covarient interface for Mock<T> such that casts between IMock<Employee> to IMock<Person> - are possible. Only covers the covariant members of Mock<T>. - - - - - Exposes the mocked object instance. - - - - - Behavior of the mock, according to the value set in the constructor. - - - - - Whether the base member virtual implementation will be called - for mocked classes if no setup is matched. Defaults to . - - - - - Specifies the behavior to use when returning default values for - unexpected invocations on loose mocks. - - - - - Get an eventInfo for a given event name. Search type ancestors depth first if necessary. - - Name of the event, with the set_ or get_ prefix already removed - - - - Get an eventInfo for a given event name. Search type ancestors depth first if necessary. - Searches also in non public events. - - Name of the event, with the set_ or get_ prefix already removed - - - - Given a type return all of its ancestors, both types and interfaces. - - The type to find immediate ancestors of - - - - Defines the Callback verb and overloads. - - - - - Helper interface used to hide the base - members from the fluent API to make it much cleaner - in Visual Studio intellisense. - - - - - - - - - - - - - - - - - Specifies a callback to invoke when the method is called. - - The callback method to invoke. - - The following example specifies a callback to set a boolean - value that can be used later: - - var called = false; - mock.Setup(x => x.Execute()) - .Callback(() => called = true); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The argument type of the invoked method. - The callback method to invoke. - - Invokes the given callback with the concrete invocation argument value. - - Notice how the specific string argument is retrieved by simply declaring - it as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute(It.IsAny<string>())) - .Callback((string command) => Console.WriteLine(command)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2) => Console.WriteLine(arg1 + arg2)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3) => Console.WriteLine(arg1 + arg2 + arg3)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3, string arg4) => Console.WriteLine(arg1 + arg2 + arg3 + arg4)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3, string arg4, string arg5) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The type of the thirteenth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The type of the thirteenth argument of the invoked method. - The type of the fourteenth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13, string arg14) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The type of the thirteenth argument of the invoked method. - The type of the fourteenth argument of the invoked method. - The type of the fifteenth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13, string arg14, string arg15) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14 + arg15)); - - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The type of the thirteenth argument of the invoked method. - The type of the fourteenth argument of the invoked method. - The type of the fifteenth argument of the invoked method. - The type of the sixteenth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13, string arg14, string arg15, string arg16) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14 + arg15 + arg16)); - - - - - - Defines the Callback verb and overloads for callbacks on - setups that return a value. - - Mocked type. - Type of the return value of the setup. - - - - Specifies a callback to invoke when the method is called. - - The callback method to invoke. - - The following example specifies a callback to set a boolean value that can be used later: - - var called = false; - mock.Setup(x => x.Execute()) - .Callback(() => called = true) - .Returns(true); - - Note that in the case of value-returning methods, after the Callback - call you can still specify the return value. - - - - - Specifies a callback to invoke when the method is called that receives the original arguments. - - The type of the argument of the invoked method. - Callback method to invoke. - - Invokes the given callback with the concrete invocation argument value. - - Notice how the specific string argument is retrieved by simply declaring - it as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute(It.IsAny<string>())) - .Callback(command => Console.WriteLine(command)) - .Returns(true); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2) => Console.WriteLine(arg1 + arg2)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3) => Console.WriteLine(arg1 + arg2 + arg3)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3, arg4) => Console.WriteLine(arg1 + arg2 + arg3 + arg4)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3, arg4, arg5) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3, arg4, arg5, arg6) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The type of the thirteenth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The type of the thirteenth argument of the invoked method. - The type of the fourteenth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The type of the thirteenth argument of the invoked method. - The type of the fourteenth argument of the invoked method. - The type of the fifteenth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14 + arg15)); - - - - - - Specifies a callback to invoke when the method is called that receives the original - arguments. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The type of the thirteenth argument of the invoked method. - The type of the fourteenth argument of the invoked method. - The type of the fifteenth argument of the invoked method. - The type of the sixteenth argument of the invoked method. - The callback method to invoke. - A reference to interface. - - Invokes the given callback with the concrete invocation arguments values. - - Notice how the specific arguments are retrieved by simply declaring - them as part of the lambda expression for the callback: - - - mock.Setup(x => x.Execute( - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>(), - It.IsAny<string>())) - .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14 + arg15 + arg16)); - - - - - - Defines the Raises verb. - - - - - Specifies the event that will be raised - when the setup is met. - - An expression that represents an event attach or detach action. - The event arguments to pass for the raised event. - - The following example shows how to raise an event when - the setup is met: - - var mock = new Mock<IContainer>(); - - mock.Setup(add => add.Add(It.IsAny<string>(), It.IsAny<object>())) - .Raises(add => add.Added += null, EventArgs.Empty); - - - - - - Specifies the event that will be raised - when the setup is matched. - - An expression that represents an event attach or detach action. - A function that will build the - to pass when raising the event. - - - - - Specifies the custom event that will be raised - when the setup is matched. - - An expression that represents an event attach or detach action. - The arguments to pass to the custom delegate (non EventHandler-compatible). - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - The type of the fourth argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - The type of the fourth argument received by the expected invocation. - The type of the fifth argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - The type of the fourth argument received by the expected invocation. - The type of the fifth argument received by the expected invocation. - The type of the sixth argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - The type of the fourth argument received by the expected invocation. - The type of the fifth argument received by the expected invocation. - The type of the sixth argument received by the expected invocation. - The type of the seventh argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - The type of the fourth argument received by the expected invocation. - The type of the fifth argument received by the expected invocation. - The type of the sixth argument received by the expected invocation. - The type of the seventh argument received by the expected invocation. - The type of the eighth argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - The type of the fourth argument received by the expected invocation. - The type of the fifth argument received by the expected invocation. - The type of the sixth argument received by the expected invocation. - The type of the seventh argument received by the expected invocation. - The type of the eighth argument received by the expected invocation. - The type of the nineth argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - The type of the fourth argument received by the expected invocation. - The type of the fifth argument received by the expected invocation. - The type of the sixth argument received by the expected invocation. - The type of the seventh argument received by the expected invocation. - The type of the eighth argument received by the expected invocation. - The type of the nineth argument received by the expected invocation. - The type of the tenth argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - The type of the fourth argument received by the expected invocation. - The type of the fifth argument received by the expected invocation. - The type of the sixth argument received by the expected invocation. - The type of the seventh argument received by the expected invocation. - The type of the eighth argument received by the expected invocation. - The type of the nineth argument received by the expected invocation. - The type of the tenth argument received by the expected invocation. - The type of the eleventh argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - The type of the fourth argument received by the expected invocation. - The type of the fifth argument received by the expected invocation. - The type of the sixth argument received by the expected invocation. - The type of the seventh argument received by the expected invocation. - The type of the eighth argument received by the expected invocation. - The type of the nineth argument received by the expected invocation. - The type of the tenth argument received by the expected invocation. - The type of the eleventh argument received by the expected invocation. - The type of the twelfth argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - The type of the fourth argument received by the expected invocation. - The type of the fifth argument received by the expected invocation. - The type of the sixth argument received by the expected invocation. - The type of the seventh argument received by the expected invocation. - The type of the eighth argument received by the expected invocation. - The type of the nineth argument received by the expected invocation. - The type of the tenth argument received by the expected invocation. - The type of the eleventh argument received by the expected invocation. - The type of the twelfth argument received by the expected invocation. - The type of the thirteenth argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - The type of the fourth argument received by the expected invocation. - The type of the fifth argument received by the expected invocation. - The type of the sixth argument received by the expected invocation. - The type of the seventh argument received by the expected invocation. - The type of the eighth argument received by the expected invocation. - The type of the nineth argument received by the expected invocation. - The type of the tenth argument received by the expected invocation. - The type of the eleventh argument received by the expected invocation. - The type of the twelfth argument received by the expected invocation. - The type of the thirteenth argument received by the expected invocation. - The type of the fourteenth argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - The type of the fourth argument received by the expected invocation. - The type of the fifth argument received by the expected invocation. - The type of the sixth argument received by the expected invocation. - The type of the seventh argument received by the expected invocation. - The type of the eighth argument received by the expected invocation. - The type of the nineth argument received by the expected invocation. - The type of the tenth argument received by the expected invocation. - The type of the eleventh argument received by the expected invocation. - The type of the twelfth argument received by the expected invocation. - The type of the thirteenth argument received by the expected invocation. - The type of the fourteenth argument received by the expected invocation. - The type of the fifteenth argument received by the expected invocation. - - - - - Specifies the event that will be raised when the setup is matched. - - The expression that represents an event attach or detach action. - The function that will build the - to pass when raising the event. - The type of the first argument received by the expected invocation. - The type of the second argument received by the expected invocation. - The type of the third argument received by the expected invocation. - The type of the fourth argument received by the expected invocation. - The type of the fifth argument received by the expected invocation. - The type of the sixth argument received by the expected invocation. - The type of the seventh argument received by the expected invocation. - The type of the eighth argument received by the expected invocation. - The type of the nineth argument received by the expected invocation. - The type of the tenth argument received by the expected invocation. - The type of the eleventh argument received by the expected invocation. - The type of the twelfth argument received by the expected invocation. - The type of the thirteenth argument received by the expected invocation. - The type of the fourteenth argument received by the expected invocation. - The type of the fifteenth argument received by the expected invocation. - The type of the sixteenth argument received by the expected invocation. - - - - - Defines the Returns verb. - - Mocked type. - Type of the return value from the expression. - - - - Specifies the value to return. - - The value to return, or . - - Return a true value from the method call: - - mock.Setup(x => x.Execute("ping")) - .Returns(true); - - - - - - Specifies a function that will calculate the value to return from the method. - - The function that will calculate the return value. - - Return a calculated value when the method is called: - - mock.Setup(x => x.Execute("ping")) - .Returns(() => returnValues[0]); - - The lambda expression to retrieve the return value is lazy-executed, - meaning that its value may change depending on the moment the method - is executed and the value the returnValues array has at - that moment. - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the argument of the invoked method. - The function that will calculate the return value. - - Return a calculated value which is evaluated lazily at the time of the invocation. - - The lookup list can change between invocations and the setup - will return different values accordingly. Also, notice how the specific - string argument is retrieved by simply declaring it as part of the lambda - expression: - - - mock.Setup(x => x.Execute(It.IsAny<string>())) - .Returns((string command) => returnValues[command]); - - - - - - Calls the real method of the object and returns its return value. - - The value calculated by the real method of the object. - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2) => arg1 + arg2); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3) => arg1 + arg2 + arg3); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3, string arg4) => arg1 + arg2 + arg3 + arg4); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3, string arg4, string arg5) => arg1 + arg2 + arg3 + arg4 + arg5); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The type of the thirteenth argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The type of the thirteenth argument of the invoked method. - The type of the fourteenth argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13, string arg14) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The type of the thirteenth argument of the invoked method. - The type of the fourteenth argument of the invoked method. - The type of the fifteenth argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13, string arg14, string arg15) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14 + arg15); - - - - - - Specifies a function that will calculate the value to return from the method, - retrieving the arguments for the invocation. - - The type of the first argument of the invoked method. - The type of the second argument of the invoked method. - The type of the third argument of the invoked method. - The type of the fourth argument of the invoked method. - The type of the fifth argument of the invoked method. - The type of the sixth argument of the invoked method. - The type of the seventh argument of the invoked method. - The type of the eighth argument of the invoked method. - The type of the nineth argument of the invoked method. - The type of the tenth argument of the invoked method. - The type of the eleventh argument of the invoked method. - The type of the twelfth argument of the invoked method. - The type of the thirteenth argument of the invoked method. - The type of the fourteenth argument of the invoked method. - The type of the fifteenth argument of the invoked method. - The type of the sixteenth argument of the invoked method. - The function that will calculate the return value. - Returns a calculated value which is evaluated lazily at the time of the invocation. - - - The return value is calculated from the value of the actual method invocation arguments. - Notice how the arguments are retrieved by simply declaring them as part of the lambda - expression: - - - mock.Setup(x => x.Execute( - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>(), - It.IsAny<int>())) - .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13, string arg14, string arg15, string arg16) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14 + arg15 + arg16); - - - - - - Hook used to tells Castle which methods to proxy in mocked classes. - - Here we proxy the default methods Castle suggests (everything Object's methods) - plus Object.ToString(), so we can give mocks useful default names. - - This is required to allow Moq to mock ToString on proxy *class* implementations. - - - - - Extends AllMethodsHook.ShouldInterceptMethod to also intercept Object.ToString(). - - - - - The base class used for all our interface-inheriting proxies, which overrides the default - Object.ToString() behavior, to route it via the mock by default, unless overriden by a - real implementation. - - This is required to allow Moq to mock ToString on proxy *interface* implementations. - - - This is internal to Moq and should not be generally used. - - Unfortunately it must be public, due to cross-assembly visibility issues with reflection, - see github.com/Moq/moq4/issues/98 for details. - - - - - Overrides the default ToString implementation to instead find the mock for this mock.Object, - and return MockName + '.Object' as the mocked object's ToString, to make it easy to relate - mocks and mock object instances in error messages. - - - - - Defines async extension methods on IReturns. - - - - - Allows to specify the return value of an asynchronous method. - - - - - Allows to specify the exception thrown by an asynchronous method. - - - - - Language for ReturnSequence - - - - - Returns value - - - - - Throws an exception - - - - - Throws an exception - - - - - Calls original method - - - - - The first method call or member access will be the - last segment of the expression (depth-first traversal), - which is the one we have to Setup rather than FluentMock. - And the last one is the one we have to Mock.Get rather - than FluentMock. - - - - - Base class for mocks and static helper class with methods that - apply to mocked objects, such as to - retrieve a from an object instance. - - - - - Creates an mock object of the indicated type. - - The type of the mocked object. - The mocked object created. - - - - Creates an mock object of the indicated type. - - The predicate with the specification of how the mocked object should behave. - The type of the mocked object. - The mocked object created. - - - - Initializes a new instance of the class. - - - - - Retrieves the mock object for the given object instance. - - Type of the mock to retrieve. Can be omitted as it's inferred - from the object instance passed in as the instance. - The instance of the mocked object.The mock associated with the mocked object. - The received instance - was not created by Moq. - - The following example shows how to add a new setup to an object - instance which is not the original but rather - the object associated with it: - - // Typed instance, not the mock, is retrieved from some test API. - HttpContextBase context = GetMockContext(); - - // context.Request is the typed object from the "real" API - // so in order to add a setup to it, we need to get - // the mock that "owns" it - Mock<HttpRequestBase> request = Mock.Get(context.Request); - mock.Setup(req => req.AppRelativeCurrentExecutionFilePath) - .Returns(tempUrl); - - - - - - Returns the mocked object value. - - - - - Verifies that all verifiable expectations have been met. - - This example sets up an expectation and marks it as verifiable. After - the mock is used, a Verify() call is issued on the mock - to ensure the method in the setup was invoked: - - var mock = new Mock<IWarehouse>(); - this.Setup(x => x.HasInventory(TALISKER, 50)).Verifiable().Returns(true); - ... - // other test code - ... - // Will throw if the test code has didn't call HasInventory. - this.Verify(); - - Not all verifiable expectations were met. - - - - Verifies all expectations regardless of whether they have - been flagged as verifiable. - - This example sets up an expectation without marking it as verifiable. After - the mock is used, a call is issued on the mock - to ensure that all expectations are met: - - var mock = new Mock<IWarehouse>(); - this.Setup(x => x.HasInventory(TALISKER, 50)).Returns(true); - ... - // other test code - ... - // Will throw if the test code has didn't call HasInventory, even - // that expectation was not marked as verifiable. - this.VerifyAll(); - - At least one expectation was not met. - - - - Gets the interceptor target for the given expression and root mock, - building the intermediate hierarchy of mock objects if necessary. - - - - - Raises the associated event with the given - event argument data. - - - - - Raises the associated event with the given - event argument data. - - - - - Adds an interface implementation to the mock, - allowing setups to be specified for it. - - This method can only be called before the first use - of the mock property, at which - point the runtime type has already been generated - and no more interfaces can be added to it. - - Also, must be an - interface and not a class, which must be specified - when creating the mock instead. - - - The mock type - has already been generated by accessing the property. - - The specified - is not an interface. - - The following example creates a mock for the main interface - and later adds to it to verify - it's called by the consumer code: - - var mock = new Mock<IProcessor>(); - mock.Setup(x => x.Execute("ping")); - - // add IDisposable interface - var disposable = mock.As<IDisposable>(); - disposable.Setup(d => d.Dispose()).Verifiable(); - - Type of interface to cast the mock to. - - - - - - - Behavior of the mock, according to the value set in the constructor. - - - - - Whether the base member virtual implementation will be called - for mocked classes if no setup is matched. Defaults to . - - - - - Specifies the behavior to use when returning default values for - unexpected invocations on loose mocks. - - - - - Gets the mocked object instance. - - - - - Retrieves the type of the mocked object, its generic type argument. - This is used in the auto-mocking of hierarchy access. - - - - - If this is a mock of a delegate, this property contains the method - on the autogenerated interface so that we can convert setup + verify - expressions on the delegate into expressions on the interface proxy. - - - - - Allows to check whether expression conversion to the - must be performed on the mock, without causing unnecessarily early initialization of - the mock instance, which breaks As{T}. - - - - - Specifies the class that will determine the default - value to return when invocations are made that - have no setups and need to return a default - value (for loose mocks). - - - - - Exposes the list of extra interfaces implemented by the mock. - - - - - Utility repository class to use to construct multiple - mocks when consistent verification is - desired for all of them. - - - If multiple mocks will be created during a test, passing - the desired (if different than the - or the one - passed to the repository constructor) and later verifying each - mock can become repetitive and tedious. - - This repository class helps in that scenario by providing a - simplified creation of multiple mocks with a default - (unless overriden by calling - ) and posterior verification. - - - - The following is a straightforward example on how to - create and automatically verify strict mocks using a : - - var repository = new MockRepository(MockBehavior.Strict); - - var foo = repository.Create<IFoo>(); - var bar = repository.Create<IBar>(); - - // no need to call Verifiable() on the setup - // as we'll be validating all of them anyway. - foo.Setup(f => f.Do()); - bar.Setup(b => b.Redo()); - - // exercise the mocks here - - repository.VerifyAll(); - // At this point all setups are already checked - // and an optional MockException might be thrown. - // Note also that because the mocks are strict, any invocation - // that doesn't have a matching setup will also throw a MockException. - - The following examples shows how to setup the repository - to create loose mocks and later verify only verifiable setups: - - var repository = new MockRepository(MockBehavior.Loose); - - var foo = repository.Create<IFoo>(); - var bar = repository.Create<IBar>(); - - // this setup will be verified when we verify the repository - foo.Setup(f => f.Do()).Verifiable(); - - // this setup will NOT be verified - foo.Setup(f => f.Calculate()); - - // this setup will be verified when we verify the repository - bar.Setup(b => b.Redo()).Verifiable(); - - // exercise the mocks here - // note that because the mocks are Loose, members - // called in the interfaces for which no matching - // setups exist will NOT throw exceptions, - // and will rather return default values. - - repository.Verify(); - // At this point verifiable setups are already checked - // and an optional MockException might be thrown. - - The following examples shows how to setup the repository with a - default strict behavior, overriding that default for a - specific mock: - - var repository = new MockRepository(MockBehavior.Strict); - - // this particular one we want loose - var foo = repository.Create<IFoo>(MockBehavior.Loose); - var bar = repository.Create<IBar>(); - - // specify setups - - // exercise the mocks here - - repository.Verify(); - - - - - - - Utility factory class to use to construct multiple - mocks when consistent verification is - desired for all of them. - - - If multiple mocks will be created during a test, passing - the desired (if different than the - or the one - passed to the factory constructor) and later verifying each - mock can become repetitive and tedious. - - This factory class helps in that scenario by providing a - simplified creation of multiple mocks with a default - (unless overriden by calling - ) and posterior verification. - - - - The following is a straightforward example on how to - create and automatically verify strict mocks using a : - - var factory = new MockFactory(MockBehavior.Strict); - - var foo = factory.Create<IFoo>(); - var bar = factory.Create<IBar>(); - - // no need to call Verifiable() on the setup - // as we'll be validating all of them anyway. - foo.Setup(f => f.Do()); - bar.Setup(b => b.Redo()); - - // exercise the mocks here - - factory.VerifyAll(); - // At this point all setups are already checked - // and an optional MockException might be thrown. - // Note also that because the mocks are strict, any invocation - // that doesn't have a matching setup will also throw a MockException. - - The following examples shows how to setup the factory - to create loose mocks and later verify only verifiable setups: - - var factory = new MockFactory(MockBehavior.Loose); - - var foo = factory.Create<IFoo>(); - var bar = factory.Create<IBar>(); - - // this setup will be verified when we verify the factory - foo.Setup(f => f.Do()).Verifiable(); - - // this setup will NOT be verified - foo.Setup(f => f.Calculate()); - - // this setup will be verified when we verify the factory - bar.Setup(b => b.Redo()).Verifiable(); - - // exercise the mocks here - // note that because the mocks are Loose, members - // called in the interfaces for which no matching - // setups exist will NOT throw exceptions, - // and will rather return default values. - - factory.Verify(); - // At this point verifiable setups are already checked - // and an optional MockException might be thrown. - - The following examples shows how to setup the factory with a - default strict behavior, overriding that default for a - specific mock: - - var factory = new MockFactory(MockBehavior.Strict); - - // this particular one we want loose - var foo = factory.Create<IFoo>(MockBehavior.Loose); - var bar = factory.Create<IBar>(); - - // specify setups - - // exercise the mocks here - - factory.Verify(); - - - - - - - Initializes the factory with the given - for newly created mocks from the factory. - - The behavior to use for mocks created - using the factory method if not overriden - by using the overload. - - - - Creates a new mock with the default - specified at factory construction time. - - Type to mock. - A new . - - - var factory = new MockFactory(MockBehavior.Strict); - - var foo = factory.Create<IFoo>(); - // use mock on tests - - factory.VerifyAll(); - - - - - - Creates a new mock with the default - specified at factory construction time and with the - the given constructor arguments for the class. - - - The mock will try to find the best match constructor given the - constructor arguments, and invoke that to initialize the instance. - This applies only to classes, not interfaces. - - Type to mock. - Constructor arguments for mocked classes. - A new . - - - var factory = new MockFactory(MockBehavior.Default); - - var mock = factory.Create<MyBase>("Foo", 25, true); - // use mock on tests - - factory.Verify(); - - - - - - Creates a new mock with the given . - - Type to mock. - Behavior to use for the mock, which overrides - the default behavior specified at factory construction time. - A new . - - The following example shows how to create a mock with a different - behavior to that specified as the default for the factory: - - var factory = new MockFactory(MockBehavior.Strict); - - var foo = factory.Create<IFoo>(MockBehavior.Loose); - - - - - - Creates a new mock with the given - and with the the given constructor arguments for the class. - - - The mock will try to find the best match constructor given the - constructor arguments, and invoke that to initialize the instance. - This applies only to classes, not interfaces. - - Type to mock. - Behavior to use for the mock, which overrides - the default behavior specified at factory construction time. - Constructor arguments for mocked classes. - A new . - - The following example shows how to create a mock with a different - behavior to that specified as the default for the factory, passing - constructor arguments: - - var factory = new MockFactory(MockBehavior.Default); - - var mock = factory.Create<MyBase>(MockBehavior.Strict, "Foo", 25, true); - - - - - - Implements creation of a new mock within the factory. - - Type to mock. - The behavior for the new mock. - Optional arguments for the construction of the mock. - - - - Verifies all verifiable expectations on all mocks created - by this factory. - - - One or more mocks had expectations that were not satisfied. - - - - Verifies all verifiable expectations on all mocks created - by this factory. - - - One or more mocks had expectations that were not satisfied. - - - - Invokes for each mock - in , and accumulates the resulting - that might be - thrown from the action. - - The action to execute against - each mock. - - - - Whether the base member virtual implementation will be called - for mocked classes if no setup is matched. Defaults to . - - - - - Specifies the behavior to use when returning default values for - unexpected invocations on loose mocks. - - - - - Gets the mocks that have been created by this factory and - that will get verified together. - - - - - Access the universe of mocks of the given type, to retrieve those - that behave according to the LINQ query specification. - - The type of the mocked object to query. - - - - Access the universe of mocks of the given type, to retrieve those - that behave according to the LINQ query specification. - - The predicate with the setup expressions. - The type of the mocked object to query. - - - - Creates an mock object of the indicated type. - - The type of the mocked object. - The mocked object created. - - - - Creates an mock object of the indicated type. - - The predicate with the setup expressions. - The type of the mocked object. - The mocked object created. - - - - Creates the mock query with the underlying queriable implementation. - - - - - Wraps the enumerator inside a queryable. - - - - - Method that is turned into the actual call from .Query{T}, to - transform the queryable query into a normal enumerable query. - This method is never used directly by consumers. - - - - - Initializes the repository with the given - for newly created mocks from the repository. - - The behavior to use for mocks created - using the repository method if not overriden - by using the overload. - - - - A that returns an empty default value - for invocations that do not have setups or return values, with loose mocks. - This is the default behavior for a mock. - - - - - Interface to be implemented by classes that determine the - default value of non-expected invocations. - - - - - Defines the default value to return in all the methods returning . - The type of the return value.The value to set as default. - - - - Provides a value for the given member and arguments. - - The member to provide a default value for. - - - - - The intention of is to create a more readable - string representation for the failure message. - - - - - Implements the fluent API. - - - - - Defines the Throws verb. - - - - - Specifies the exception to throw when the method is invoked. - - Exception instance to throw. - - This example shows how to throw an exception when the method is - invoked with an empty string argument: - - mock.Setup(x => x.Execute("")) - .Throws(new ArgumentException()); - - - - - - Specifies the type of exception to throw when the method is invoked. - - Type of exception to instantiate and throw when the setup is matched. - - This example shows how to throw an exception when the method is - invoked with an empty string argument: - - mock.Setup(x => x.Execute("")) - .Throws<ArgumentException>(); - - - - - - Implements the fluent API. - - - - - Defines occurrence members to constraint setups. - - - - - The expected invocation can happen at most once. - - - - var mock = new Mock<ICommand>(); - mock.Setup(foo => foo.Execute("ping")) - .AtMostOnce(); - - - - - - The expected invocation can happen at most specified number of times. - - The number of times to accept calls. - - - var mock = new Mock<ICommand>(); - mock.Setup(foo => foo.Execute("ping")) - .AtMost( 5 ); - - - - - - Defines the Verifiable verb. - - - - - Marks the expectation as verifiable, meaning that a call - to will check if this particular - expectation was met. - - - The following example marks the expectation as verifiable: - - mock.Expect(x => x.Execute("ping")) - .Returns(true) - .Verifiable(); - - - - - - Marks the expectation as verifiable, meaning that a call - to will check if this particular - expectation was met, and specifies a message for failures. - - - The following example marks the expectation as verifiable: - - mock.Expect(x => x.Execute("ping")) - .Returns(true) - .Verifiable("Ping should be executed always!"); - - - - - - Implements the fluent API. - - - - - We need this non-generics base class so that - we can use from - generic code. - - - - - Implements the fluent API. - - - - - Implements the fluent API. - - - - - Implements the fluent API. - - - - - Defines the Callback verb for property getter setups. - - - Mocked type. - Type of the property. - - - - Specifies a callback to invoke when the property is retrieved. - - Callback method to invoke. - - Invokes the given callback with the property value being set. - - mock.SetupGet(x => x.Suspended) - .Callback(() => called = true) - .Returns(true); - - - - - - Implements the fluent API. - - - - - Defines the Returns verb for property get setups. - - Mocked type. - Type of the property. - - - - Specifies the value to return. - - The value to return, or . - - Return a true value from the property getter call: - - mock.SetupGet(x => x.Suspended) - .Returns(true); - - - - - - Specifies a function that will calculate the value to return for the property. - - The function that will calculate the return value. - - Return a calculated value when the property is retrieved: - - mock.SetupGet(x => x.Suspended) - .Returns(() => returnValues[0]); - - The lambda expression to retrieve the return value is lazy-executed, - meaning that its value may change depending on the moment the property - is retrieved and the value the returnValues array has at - that moment. - - - - - Calls the real property of the object and returns its return value. - - The value calculated by the real property of the object. - - - - Implements the fluent API. - - - - - Provides additional methods on mocks. - - - Those methods are useful for Testeroids support. - - - - - Resets the calls previously made on the specified mock. - - The mock whose calls need to be reset. - - - - Helper class to setup a full trace between many mocks - - - - - Initialize a trace setup - - - - - Allow sequence to be repeated - - - - - define nice api - - - - - Perform an expectation in the trace. - - - - - Marks a method as a matcher, which allows complete replacement - of the built-in class with your own argument - matching rules. - - - This feature has been deprecated in favor of the new - and simpler . - - - The argument matching is used to determine whether a concrete - invocation in the mock matches a given setup. This - matching mechanism is fully extensible. - - - There are two parts of a matcher: the compiler matcher - and the runtime matcher. - - - Compiler matcher - Used to satisfy the compiler requirements for the - argument. Needs to be a method optionally receiving any arguments - you might need for the matching, but with a return type that - matches that of the argument. - - Let's say I want to match a lists of orders that contains - a particular one. I might create a compiler matcher like the following: - - - public static class Orders - { - [Matcher] - public static IEnumerable<Order> Contains(Order order) - { - return null; - } - } - - Now we can invoke this static method instead of an argument in an - invocation: - - var order = new Order { ... }; - var mock = new Mock<IRepository<Order>>(); - - mock.Setup(x => x.Save(Orders.Contains(order))) - .Throws<ArgumentException>(); - - Note that the return value from the compiler matcher is irrelevant. - This method will never be called, and is just used to satisfy the - compiler and to signal Moq that this is not a method that we want - to be invoked at runtime. - - - - Runtime matcher - - The runtime matcher is the one that will actually perform evaluation - when the test is run, and is defined by convention to have the - same signature as the compiler matcher, but where the return - value is the first argument to the call, which contains the - object received by the actual invocation at runtime: - - public static bool Contains(IEnumerable<Order> orders, Order order) - { - return orders.Contains(order); - } - - At runtime, the mocked method will be invoked with a specific - list of orders. This value will be passed to this runtime - matcher as the first argument, while the second argument is the - one specified in the setup (x.Save(Orders.Contains(order))). - - The boolean returned determines whether the given argument has been - matched. If all arguments to the expected method are matched, then - the setup matches and is evaluated. - - - - - - Using this extensible infrastructure, you can easily replace the entire - set of matchers with your own. You can also avoid the - typical (and annoying) lengthy expressions that result when you have - multiple arguments that use generics. - - - The following is the complete example explained above: - - public static class Orders - { - [Matcher] - public static IEnumerable<Order> Contains(Order order) - { - return null; - } - - public static bool Contains(IEnumerable<Order> orders, Order order) - { - return orders.Contains(order); - } - } - - And the concrete test using this matcher: - - var order = new Order { ... }; - var mock = new Mock<IRepository<Order>>(); - - mock.Setup(x => x.Save(Orders.Contains(order))) - .Throws<ArgumentException>(); - - // use mock, invoke Save, and have the matcher filter. - - - - - - Provides a mock implementation of . - - Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. - - The behavior of the mock with regards to the setups and the actual calls is determined - by the optional that can be passed to the - constructor. - - Type to mock, which can be an interface or a class. - The following example shows establishing setups with specific values - for method invocations: - - // Arrange - var order = new Order(TALISKER, 50); - var mock = new Mock<IWarehouse>(); - - mock.Setup(x => x.HasInventory(TALISKER, 50)).Returns(true); - - // Act - order.Fill(mock.Object); - - // Assert - Assert.True(order.IsFilled); - - The following example shows how to use the class - to specify conditions for arguments instead of specific values: - - // Arrange - var order = new Order(TALISKER, 50); - var mock = new Mock<IWarehouse>(); - - // shows how to expect a value within a range - mock.Setup(x => x.HasInventory( - It.IsAny<string>(), - It.IsInRange(0, 100, Range.Inclusive))) - .Returns(false); - - // shows how to throw for unexpected calls. - mock.Setup(x => x.Remove( - It.IsAny<string>(), - It.IsAny<int>())) - .Throws(new InvalidOperationException()); - - // Act - order.Fill(mock.Object); - - // Assert - Assert.False(order.IsFilled); - - - - - - Obsolete. - - - - - Obsolete. - - - - - Obsolete. - - - - - Obsolete. - - - - - Obsolete. - - - - - Ctor invoked by AsTInterface exclusively. - - - - - Initializes an instance of the mock with default behavior. - - var mock = new Mock<IFormatProvider>(); - - - - - Initializes an instance of the mock with default behavior and with - the given constructor arguments for the class. (Only valid when is a class) - - The mock will try to find the best match constructor given the constructor arguments, and invoke that - to initialize the instance. This applies only for classes, not interfaces. - - var mock = new Mock<MyProvider>(someArgument, 25); - Optional constructor arguments if the mocked type is a class. - - - - Initializes an instance of the mock with the specified behavior. - - var mock = new Mock<IFormatProvider>(MockBehavior.Relaxed); - Behavior of the mock. - - - - Initializes an instance of the mock with a specific behavior with - the given constructor arguments for the class. - - The mock will try to find the best match constructor given the constructor arguments, and invoke that - to initialize the instance. This applies only to classes, not interfaces. - - var mock = new Mock<MyProvider>(someArgument, 25); - Behavior of the mock.Optional constructor arguments if the mocked type is a class. - - - - Returns the name of the mock - - - - - Returns the mocked object value. - - - - - Specifies a setup on the mocked type for a call to - to a void method. - - If more than one setup is specified for the same method or property, - the latest one wins and is the one that will be executed. - Lambda expression that specifies the expected method invocation. - - var mock = new Mock<IProcessor>(); - mock.Setup(x => x.Execute("ping")); - - - - - - Specifies a setup on the mocked type for a call to - to a value returning method. - Type of the return value. Typically omitted as it can be inferred from the expression. - If more than one setup is specified for the same method or property, - the latest one wins and is the one that will be executed. - Lambda expression that specifies the method invocation. - - mock.Setup(x => x.HasInventory("Talisker", 50)).Returns(true); - - - - - - Specifies a setup on the mocked type for a call to - to a property getter. - - If more than one setup is set for the same property getter, - the latest one wins and is the one that will be executed. - Type of the property. Typically omitted as it can be inferred from the expression.Lambda expression that specifies the property getter. - - mock.SetupGet(x => x.Suspended) - .Returns(true); - - - - - - Specifies a setup on the mocked type for a call to - to a property setter. - - If more than one setup is set for the same property setter, - the latest one wins and is the one that will be executed. - - This overloads allows the use of a callback already - typed for the property type. - - Type of the property. Typically omitted as it can be inferred from the expression.The Lambda expression that sets a property to a value. - - mock.SetupSet(x => x.Suspended = true); - - - - - - Specifies a setup on the mocked type for a call to - to a property setter. - - If more than one setup is set for the same property setter, - the latest one wins and is the one that will be executed. - Lambda expression that sets a property to a value. - - mock.SetupSet(x => x.Suspended = true); - - - - - - Specifies that the given property should have "property behavior", - meaning that setting its value will cause it to be saved and - later returned when the property is requested. (this is also - known as "stubbing"). - - Type of the property, inferred from the property - expression (does not need to be specified). - Property expression to stub. - If you have an interface with an int property Value, you might - stub it using the following straightforward call: - - var mock = new Mock<IHaveValue>(); - mock.Stub(v => v.Value); - - After the Stub call has been issued, setting and - retrieving the object value will behave as expected: - - IHaveValue v = mock.Object; - - v.Value = 5; - Assert.Equal(5, v.Value); - - - - - - Specifies that the given property should have "property behavior", - meaning that setting its value will cause it to be saved and - later returned when the property is requested. This overload - allows setting the initial value for the property. (this is also - known as "stubbing"). - - Type of the property, inferred from the property - expression (does not need to be specified). - Property expression to stub.Initial value for the property. - If you have an interface with an int property Value, you might - stub it using the following straightforward call: - - var mock = new Mock<IHaveValue>(); - mock.SetupProperty(v => v.Value, 5); - - After the SetupProperty call has been issued, setting and - retrieving the object value will behave as expected: - - IHaveValue v = mock.Object; - // Initial value was stored - Assert.Equal(5, v.Value); - - // New value set which changes the initial value - v.Value = 6; - Assert.Equal(6, v.Value); - - - - - - Specifies that the all properties on the mock should have "property behavior", - meaning that setting its value will cause it to be saved and - later returned when the property is requested. (this is also - known as "stubbing"). The default value for each property will be the - one generated as specified by the property for the mock. - - If the mock is set to , - the mocked default values will also get all properties setup recursively. - - - - - - - - Verifies that a specific invocation matching the given expression was performed on the mock. Use - in conjuntion with the default . - - This example assumes that the mock has been used, and later we want to verify that a given - invocation with specific parameters was performed: - - var mock = new Mock<IProcessor>(); - // exercise mock - //... - // Will throw if the test code didn't call Execute with a "ping" string argument. - mock.Verify(proc => proc.Execute("ping")); - - The invocation was not performed on the mock.Expression to verify. - - - - Verifies that a specific invocation matching the given expression was performed on the mock. Use - in conjuntion with the default . - - The invocation was not call the times specified by - . - Expression to verify.The number of times a method is allowed to be called. - - - - Verifies that a specific invocation matching the given expression was performed on the mock. Use - in conjuntion with the default . - - The invocation was not call the times specified by - . - Expression to verify.The number of times a method is allowed to be called. - - - - Verifies that a specific invocation matching the given expression was performed on the mock, - specifying a failure error message. Use in conjuntion with the default - . - - This example assumes that the mock has been used, and later we want to verify that a given - invocation with specific parameters was performed: - - var mock = new Mock<IProcessor>(); - // exercise mock - //... - // Will throw if the test code didn't call Execute with a "ping" string argument. - mock.Verify(proc => proc.Execute("ping")); - - The invocation was not performed on the mock.Expression to verify.Message to show if verification fails. - - - - Verifies that a specific invocation matching the given expression was performed on the mock, - specifying a failure error message. Use in conjuntion with the default - . - - The invocation was not call the times specified by - . - Expression to verify.The number of times a method is allowed to be called.Message to show if verification fails. - - - - Verifies that a specific invocation matching the given expression was performed on the mock, - specifying a failure error message. Use in conjuntion with the default - . - - The invocation was not call the times specified by - . - Expression to verify.The number of times a method is allowed to be called.Message to show if verification fails. - - - - Verifies that a specific invocation matching the given expression was performed on the mock. Use - in conjuntion with the default . - - This example assumes that the mock has been used, and later we want to verify that a given - invocation with specific parameters was performed: - - var mock = new Mock<IWarehouse>(); - // exercise mock - //... - // Will throw if the test code didn't call HasInventory. - mock.Verify(warehouse => warehouse.HasInventory(TALISKER, 50)); - - The invocation was not performed on the mock.Expression to verify.Type of return value from the expression. - - - - Verifies that a specific invocation matching the given - expression was performed on the mock. Use in conjuntion - with the default . - - The invocation was not call the times specified by - . - Expression to verify.The number of times a method is allowed to be called.Type of return value from the expression. - - - - Verifies that a specific invocation matching the given - expression was performed on the mock. Use in conjuntion - with the default . - - The invocation was not call the times specified by - . - Expression to verify.The number of times a method is allowed to be called.Type of return value from the expression. - - - - Verifies that a specific invocation matching the given - expression was performed on the mock, specifying a failure - error message. - - This example assumes that the mock has been used, - and later we want to verify that a given invocation - with specific parameters was performed: - - var mock = new Mock<IWarehouse>(); - // exercise mock - //... - // Will throw if the test code didn't call HasInventory. - mock.Verify(warehouse => warehouse.HasInventory(TALISKER, 50), "When filling orders, inventory has to be checked"); - - The invocation was not performed on the mock.Expression to verify.Message to show if verification fails.Type of return value from the expression. - - - - Verifies that a specific invocation matching the given - expression was performed on the mock, specifying a failure - error message. - - The invocation was not call the times specified by - . - Expression to verify.The number of times a method is allowed to be called.Message to show if verification fails.Type of return value from the expression. - - - - Verifies that a property was read on the mock. - - This example assumes that the mock has been used, - and later we want to verify that a given property - was retrieved from it: - - var mock = new Mock<IWarehouse>(); - // exercise mock - //... - // Will throw if the test code didn't retrieve the IsClosed property. - mock.VerifyGet(warehouse => warehouse.IsClosed); - - The invocation was not performed on the mock.Expression to verify. - Type of the property to verify. Typically omitted as it can - be inferred from the expression's return type. - - - - - Verifies that a property was read on the mock. - - The invocation was not call the times specified by - . - The number of times a method is allowed to be called.Expression to verify. - Type of the property to verify. Typically omitted as it can - be inferred from the expression's return type. - - - - - Verifies that a property was read on the mock. - - The invocation was not call the times specified by - . - The number of times a method is allowed to be called.Expression to verify. - Type of the property to verify. Typically omitted as it can - be inferred from the expression's return type. - - - - - Verifies that a property was read on the mock, specifying a failure - error message. - - This example assumes that the mock has been used, - and later we want to verify that a given property - was retrieved from it: - - var mock = new Mock<IWarehouse>(); - // exercise mock - //... - // Will throw if the test code didn't retrieve the IsClosed property. - mock.VerifyGet(warehouse => warehouse.IsClosed); - - The invocation was not performed on the mock.Expression to verify.Message to show if verification fails. - Type of the property to verify. Typically omitted as it can - be inferred from the expression's return type. - - - - - Verifies that a property was read on the mock, specifying a failure - error message. - - The invocation was not call the times specified by - . - The number of times a method is allowed to be called.Expression to verify.Message to show if verification fails. - Type of the property to verify. Typically omitted as it can - be inferred from the expression's return type. - - - - - Verifies that a property was read on the mock, specifying a failure - error message. - - The invocation was not call the times specified by - . - The number of times a method is allowed to be called.Expression to verify.Message to show if verification fails. - Type of the property to verify. Typically omitted as it can - be inferred from the expression's return type. - - - - - Verifies that a property was set on the mock. - - This example assumes that the mock has been used, - and later we want to verify that a given property - was set on it: - - var mock = new Mock<IWarehouse>(); - // exercise mock - //... - // Will throw if the test code didn't set the IsClosed property. - mock.VerifySet(warehouse => warehouse.IsClosed = true); - - The invocation was not performed on the mock.Expression to verify. - - - - Verifies that a property was set on the mock. - - The invocation was not call the times specified by - . - The number of times a method is allowed to be called.Expression to verify. - - - - Verifies that a property was set on the mock. - - The invocation was not call the times specified by - . - The number of times a method is allowed to be called.Expression to verify. - - - - Verifies that a property was set on the mock, specifying - a failure message. - - This example assumes that the mock has been used, - and later we want to verify that a given property - was set on it: - - var mock = new Mock<IWarehouse>(); - // exercise mock - //... - // Will throw if the test code didn't set the IsClosed property. - mock.VerifySet(warehouse => warehouse.IsClosed = true, "Warehouse should always be closed after the action"); - - The invocation was not performed on the mock.Expression to verify.Message to show if verification fails. - - - - Verifies that a property was set on the mock, specifying - a failure message. - - The invocation was not call the times specified by - . - The number of times a method is allowed to be called.Expression to verify.Message to show if verification fails. - - - - Verifies that a property was set on the mock, specifying - a failure message. - - The invocation was not call the times specified by - . - The number of times a method is allowed to be called.Expression to verify.Message to show if verification fails. - - - - Raises the event referenced in using - the given argument. - - The argument is - invalid for the target event invocation, or the is - not an event attach or detach expression. - - The following example shows how to raise a event: - - var mock = new Mock<IViewModel>(); - - mock.Raise(x => x.PropertyChanged -= null, new PropertyChangedEventArgs("Name")); - - - This example shows how to invoke an event with a custom event arguments - class in a view that will cause its corresponding presenter to - react by changing its state: - - var mockView = new Mock<IOrdersView>(); - var presenter = new OrdersPresenter(mockView.Object); - - // Check that the presenter has no selection by default - Assert.Null(presenter.SelectedOrder); - - // Raise the event with a specific arguments data - mockView.Raise(v => v.SelectionChanged += null, new OrderEventArgs { Order = new Order("moq", 500) }); - - // Now the presenter reacted to the event, and we have a selected order - Assert.NotNull(presenter.SelectedOrder); - Assert.Equal("moq", presenter.SelectedOrder.ProductName); - - - - - - Raises the event referenced in using - the given argument for a non-EventHandler typed event. - - The arguments are - invalid for the target event invocation, or the is - not an event attach or detach expression. - - The following example shows how to raise a custom event that does not adhere to - the standard EventHandler: - - var mock = new Mock<IViewModel>(); - - mock.Raise(x => x.MyEvent -= null, "Name", bool, 25); - - - - - - Exposes the mocked object instance. - - - - - Allows naming of your mocks, so they can be easily identified in error messages (e.g. from failed assertions). - - - - - - - - Provides legacy API members as extensions so that - existing code continues to compile, but new code - doesn't see then. - - - - - Obsolete. - - - - - Obsolete. - - - - - Obsolete. - - - - - Provides additional methods on mocks. - - - Provided as extension methods as they confuse the compiler - with the overloads taking Action. - - - - - Specifies a setup on the mocked type for a call to - to a property setter, regardless of its value. - - - If more than one setup is set for the same property setter, - the latest one wins and is the one that will be executed. - - Type of the property. Typically omitted as it can be inferred from the expression. - Type of the mock. - The target mock for the setup. - Lambda expression that specifies the property setter. - - - mock.SetupSet(x => x.Suspended); - - - - This method is not legacy, but must be on an extension method to avoid - confusing the compiler with the new Action syntax. - - - - - Verifies that a property has been set on the mock, regarless of its value. - - - This example assumes that the mock has been used, - and later we want to verify that a given invocation - with specific parameters was performed: - - var mock = new Mock<IWarehouse>(); - // exercise mock - //... - // Will throw if the test code didn't set the IsClosed property. - mock.VerifySet(warehouse => warehouse.IsClosed); - - - The invocation was not performed on the mock. - Expression to verify. - The mock instance. - Mocked type. - Type of the property to verify. Typically omitted as it can - be inferred from the expression's return type. - - - - Verifies that a property has been set on the mock, specifying a failure - error message. - - - This example assumes that the mock has been used, - and later we want to verify that a given invocation - with specific parameters was performed: - - var mock = new Mock<IWarehouse>(); - // exercise mock - //... - // Will throw if the test code didn't set the IsClosed property. - mock.VerifySet(warehouse => warehouse.IsClosed); - - - The invocation was not performed on the mock. - Expression to verify. - Message to show if verification fails. - The mock instance. - Mocked type. - Type of the property to verify. Typically omitted as it can - be inferred from the expression's return type. - - - - Verifies that a property has been set on the mock, regardless - of the value but only the specified number of times. - - - This example assumes that the mock has been used, - and later we want to verify that a given invocation - with specific parameters was performed: - - var mock = new Mock<IWarehouse>(); - // exercise mock - //... - // Will throw if the test code didn't set the IsClosed property. - mock.VerifySet(warehouse => warehouse.IsClosed); - - - The invocation was not performed on the mock. - The invocation was not call the times specified by - . - The mock instance. - Mocked type. - The number of times a method is allowed to be called. - Expression to verify. - Type of the property to verify. Typically omitted as it can - be inferred from the expression's return type. - - - - Verifies that a property has been set on the mock, regardless - of the value but only the specified number of times, and specifying a failure - error message. - - - This example assumes that the mock has been used, - and later we want to verify that a given invocation - with specific parameters was performed: - - var mock = new Mock<IWarehouse>(); - // exercise mock - //... - // Will throw if the test code didn't set the IsClosed property. - mock.VerifySet(warehouse => warehouse.IsClosed); - - - The invocation was not performed on the mock. - The invocation was not call the times specified by - . - The mock instance. - Mocked type. - The number of times a method is allowed to be called. - Message to show if verification fails. - Expression to verify. - Type of the property to verify. Typically omitted as it can - be inferred from the expression's return type. - - - - Helper for sequencing return values in the same method. - - - - - Return a sequence of values, once per call. - - - - - Casts the expression to a lambda expression, removing - a cast if there's any. - - - - - Casts the body of the lambda expression to a . - - If the body is not a method call. - - - - Converts the body of the lambda expression into the referenced by it. - - - - - Checks whether the body of the lambda expression is a property access. - - - - - Checks whether the expression is a property access. - - - - - Checks whether the body of the lambda expression is a property indexer, which is true - when the expression is an whose - has - equal to . - - - - - Checks whether the expression is a property indexer, which is true - when the expression is an whose - has - equal to . - - - - - Creates an expression that casts the given expression to the - type. - - - - - TODO: remove this code when https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=331583 - is fixed. - - - - - Extracts, into a common form, information from a - around either a (for a normal method call) - or a (for a delegate invocation). - - - - - Tests if a type is a delegate type (subclasses ). - - - - - Provides partial evaluation of subtrees, whenever they can be evaluated locally. - - Matt Warren: http://blogs.msdn.com/mattwar - Documented by InSTEDD: http://www.instedd.org - - - - Performs evaluation and replacement of independent sub-trees - - The root of the expression tree. - A function that decides whether a given expression - node can be part of the local function. - A new tree with sub-trees evaluated and replaced. - - - - Performs evaluation and replacement of independent sub-trees - - The root of the expression tree. - A new tree with sub-trees evaluated and replaced. - - - - Evaluates and replaces sub-trees when first candidate is reached (top-down) - - - - - Performs bottom-up analysis to determine which nodes can possibly - be part of an evaluated sub-tree. - - - - - Ensures the given is not null. - Throws otherwise. - - - - - Ensures the given string is not null or empty. - Throws in the first case, or - in the latter. - - - - - Checks an argument to ensure it is in the specified range including the edges. - - Type of the argument to check, it must be an type. - - The expression containing the name of the argument. - The argument value to check. - The minimun allowed value for the argument. - The maximun allowed value for the argument. - - - - Checks an argument to ensure it is in the specified range excluding the edges. - - Type of the argument to check, it must be an type. - - The expression containing the name of the argument. - The argument value to check. - The minimun allowed value for the argument. - The maximun allowed value for the argument. - - - - Implemented by all generated mock object instances. - - - - - Implemented by all generated mock object instances. - - - - - Reference the Mock that contains this as the mock.Object value. - - - - - Reference the Mock that contains this as the mock.Object value. - - - - - Implements the actual interception and method invocation for - all mocks. - - - - - Implements the fluent API. - - - - - Defines the Callback verb for property setter setups. - - Type of the property. - - - - Specifies a callback to invoke when the property is set that receives the - property value being set. - - Callback method to invoke. - - Invokes the given callback with the property value being set. - - mock.SetupSet(x => x.Suspended) - .Callback((bool state) => Console.WriteLine(state)); - - - - - - Allows the specification of a matching condition for an - argument in a method invocation, rather than a specific - argument value. "It" refers to the argument being matched. - - This class allows the setup to match a method invocation - with an arbitrary value, with a value in a specified range, or - even one that matches a given predicate. - - - - - Matches any value of the given type. - - Typically used when the actual argument value for a method - call is not relevant. - - - // Throws an exception for a call to Remove with any string value. - mock.Setup(x => x.Remove(It.IsAny<string>())).Throws(new InvalidOperationException()); - - Type of the value. - - - - Matches any value of the given type, except null. - Type of the value. - - - - Matches any value that satisfies the given predicate. - Type of the argument to check.The predicate used to match the method argument. - Allows the specification of a predicate to perform matching - of method call arguments. - - This example shows how to return the value 1 whenever the argument to the - Do method is an even number. - - mock.Setup(x => x.Do(It.Is<int>(i => i % 2 == 0))) - .Returns(1); - - This example shows how to throw an exception if the argument to the - method is a negative number: - - mock.Setup(x => x.GetUser(It.Is<int>(i => i < 0))) - .Throws(new ArgumentException()); - - - - - - Matches any value that is in the range specified. - Type of the argument to check.The lower bound of the range.The upper bound of the range. - The kind of range. See . - - The following example shows how to expect a method call - with an integer argument within the 0..100 range. - - mock.Setup(x => x.HasInventory( - It.IsAny<string>(), - It.IsInRange(0, 100, Range.Inclusive))) - .Returns(false); - - - - - - Matches any value that is present in the sequence specified. - Type of the argument to check.The sequence of possible values. - The following example shows how to expect a method call - with an integer argument with value from a list. - - var values = new List<int> { 1, 2, 3 }; - - mock.Setup(x => x.HasInventory( - It.IsAny<string>(), - It.IsIn(values))) - .Returns(false); - - - - - - Matches any value that is present in the sequence specified. - Type of the argument to check.The sequence of possible values. - The following example shows how to expect a method call - with an integer argument with a value of 1, 2, or 3. - - mock.Setup(x => x.HasInventory( - It.IsAny<string>(), - It.IsIn(1, 2, 3))) - .Returns(false); - - - - - - Matches any value that is not found in the sequence specified. - Type of the argument to check.The sequence of disallowed values. - The following example shows how to expect a method call - with an integer argument with value not found from a list. - - var values = new List<int> { 1, 2, 3 }; - - mock.Setup(x => x.HasInventory( - It.IsAny<string>(), - It.IsNotIn(values))) - .Returns(false); - - - - - - Matches any value that is not found in the sequence specified. - Type of the argument to check.The sequence of disallowed values. - The following example shows how to expect a method call - with an integer argument of any value except 1, 2, or 3. - - mock.Setup(x => x.HasInventory( - It.IsAny<string>(), - It.IsNotIn(1, 2, 3))) - .Returns(false); - - - - - - Matches a string argument if it matches the given regular expression pattern. - The pattern to use to match the string argument value. - The following example shows how to expect a call to a method where the - string argument matches the given regular expression: - - mock.Setup(x => x.Check(It.IsRegex("[a-z]+"))).Returns(1); - - - - - - Matches a string argument if it matches the given regular expression pattern. - The pattern to use to match the string argument value.The options used to interpret the pattern. - The following example shows how to expect a call to a method where the - string argument matches the given regular expression, in a case insensitive way: - - mock.Setup(x => x.Check(It.IsRegex("[a-z]+", RegexOptions.IgnoreCase))).Returns(1); - - - - - - Matcher to treat static functions as matchers. - - mock.Setup(x => x.StringMethod(A.MagicString())); - - public static class A - { - [Matcher] - public static string MagicString() { return null; } - public static bool MagicString(string arg) - { - return arg == "magic"; - } - } - - Will succeed if: mock.Object.StringMethod("magic"); - and fail with any other call. - - - - - Options to customize the behavior of the mock. - - - - - Causes the mock to always throw - an exception for invocations that don't have a - corresponding setup. - - - - - Will never throw exceptions, returning default - values when necessary (null for reference types, - zero for value types or empty enumerables and arrays). - - - - - Default mock behavior, which equals . - - - - - Exception thrown by mocks when setups are not matched, - the mock is not properly setup, etc. - - - A distinct exception type is provided so that exceptions - thrown by the mock can be differentiated in tests that - expect other exceptions to be thrown (i.e. ArgumentException). - - Richer exception hierarchy/types are not provided as - tests typically should not catch or expect exceptions - from the mocks. These are typically the result of changes - in the tested class or its collaborators implementation, and - result in fixes in the mock setup so that they dissapear and - allow the test to pass. - - - - - - Supports the serialization infrastructure. - - Serialization information. - Streaming context. - - - - Supports the serialization infrastructure. - - Serialization information. - Streaming context. - - - - Indicates whether this exception is a verification fault raised by Verify() - - - - - Made internal as it's of no use for - consumers, but it's important for - our own tests. - - - - - Used by the mock factory to accumulate verification - failures. - - - - - Supports the serialization infrastructure. - - - - - A strongly-typed resource class, for looking up localized strings, etc. - - - - - Returns the cached ResourceManager instance used by this class. - - - - - Overrides the current thread's CurrentUICulture property for all - resource lookups using this strongly typed resource class. - - - - - Looks up a localized string similar to Mock type has already been initialized by accessing its Object property. Adding interfaces must be done before that.. - - - - - Looks up a localized string similar to Value cannot be an empty string.. - - - - - Looks up a localized string similar to Can only add interfaces to the mock.. - - - - - Looks up a localized string similar to Can't set return value for void method {0}.. - - - - - Looks up a localized string similar to Constructor arguments cannot be passed for delegate mocks.. - - - - - Looks up a localized string similar to Constructor arguments cannot be passed for interface mocks.. - - - - - Looks up a localized string similar to A matching constructor for the given arguments was not found on the mocked type.. - - - - - Looks up a localized string similar to Could not locate event for attach or detach method {0}.. - - - - - Looks up a localized string similar to Expression {0} involves a field access, which is not supported. Use properties instead.. - - - - - Looks up a localized string similar to Type to mock must be an interface or an abstract or non-sealed class. . - - - - - Looks up a localized string similar to Cannot retrieve a mock with the given object type {0} as it's not the main type of the mock or any of its additional interfaces. - Please cast the argument to one of the supported types: {1}. - Remember that there's no generics covariance in the CLR, so your object must be one of these types in order for the call to succeed.. - - - - - Looks up a localized string similar to The equals ("==" or "=" in VB) and the conditional 'and' ("&&" or "AndAlso" in VB) operators are the only ones supported in the query specification expression. Unsupported expression: {0}. - - - - - Looks up a localized string similar to LINQ method '{0}' not supported.. - - - - - Looks up a localized string similar to Expression contains a call to a method which is not virtual (overridable in VB) or abstract. Unsupported expression: {0}. - - - - - Looks up a localized string similar to Member {0}.{1} does not exist.. - - - - - Looks up a localized string similar to Method {0}.{1} is public. Use strong-typed Expect overload instead: - mock.Setup(x => x.{1}()); - . - - - - - Looks up a localized string similar to {0} invocation failed with mock behavior {1}. - {2}. - - - - - Looks up a localized string similar to Expected only {0} calls to {1}.. - - - - - Looks up a localized string similar to Expected only one call to {0}.. - - - - - Looks up a localized string similar to {0} - Expected invocation on the mock at least {2} times, but was {4} times: {1}. - - - - - Looks up a localized string similar to {0} - Expected invocation on the mock at least once, but was never performed: {1}. - - - - - Looks up a localized string similar to {0} - Expected invocation on the mock at most {3} times, but was {4} times: {1}. - - - - - Looks up a localized string similar to {0} - Expected invocation on the mock at most once, but was {4} times: {1}. - - - - - Looks up a localized string similar to {0} - Expected invocation on the mock between {2} and {3} times (Exclusive), but was {4} times: {1}. - - - - - Looks up a localized string similar to {0} - Expected invocation on the mock between {2} and {3} times (Inclusive), but was {4} times: {1}. - - - - - Looks up a localized string similar to {0} - Expected invocation on the mock exactly {2} times, but was {4} times: {1}. - - - - - Looks up a localized string similar to {0} - Expected invocation on the mock should never have been performed, but was {4} times: {1}. - - - - - Looks up a localized string similar to {0} - Expected invocation on the mock once, but was {4} times: {1}. - - - - - Looks up a localized string similar to All invocations on the mock must have a corresponding setup.. - - - - - Looks up a localized string similar to Object instance was not created by Moq.. - - - - - Looks up a localized string similar to Out expression must evaluate to a constant value.. - - - - - Looks up a localized string similar to Property {0}.{1} does not have a getter.. - - - - - Looks up a localized string similar to Property {0}.{1} does not exist.. - - - - - Looks up a localized string similar to Property {0}.{1} is write-only.. - - - - - Looks up a localized string similar to Property {0}.{1} is read-only.. - - - - - Looks up a localized string similar to Property {0}.{1} does not have a setter.. - - - - - Looks up a localized string similar to Cannot raise a mocked event unless it has been associated (attached) to a concrete event in a mocked object.. - - - - - Looks up a localized string similar to Ref expression must evaluate to a constant value.. - - - - - Looks up a localized string similar to Invocation needs to return a value and therefore must have a corresponding setup that provides it.. - - - - - Looks up a localized string similar to A lambda expression is expected as the argument to It.Is<T>.. - - - - - Looks up a localized string similar to Invocation {0} should not have been made.. - - - - - Looks up a localized string similar to Expression is not a method invocation: {0}. - - - - - Looks up a localized string similar to Expression is not a property access: {0}. - - - - - Looks up a localized string similar to Expression is not a property setter invocation.. - - - - - Looks up a localized string similar to Expression references a method that does not belong to the mocked object: {0}. - - - - - Looks up a localized string similar to Invalid setup on a non-virtual (overridable in VB) member: {0}. - - - - - Looks up a localized string similar to Type {0} does not implement required interface {1}. - - - - - Looks up a localized string similar to Type {0} does not from required type {1}. - - - - - Looks up a localized string similar to To specify a setup for public property {0}.{1}, use the typed overloads, such as: - mock.Setup(x => x.{1}).Returns(value); - mock.SetupGet(x => x.{1}).Returns(value); //equivalent to previous one - mock.SetupSet(x => x.{1}).Callback(callbackDelegate); - . - - - - - Looks up a localized string similar to Unsupported expression: {0}. - - - - - Looks up a localized string similar to Only property accesses are supported in intermediate invocations on a setup. Unsupported expression {0}.. - - - - - Looks up a localized string similar to Expression contains intermediate property access {0}.{1} which is of type {2} and cannot be mocked. Unsupported expression {3}.. - - - - - Looks up a localized string similar to Setter expression cannot use argument matchers that receive parameters.. - - - - - Looks up a localized string similar to Member {0} is not supported for protected mocking.. - - - - - Looks up a localized string similar to Setter expression can only use static custom matchers.. - - - - - Looks up a localized string similar to The following setups were not matched: - {0}. - - - - - Looks up a localized string similar to Invalid verify on a non-virtual (overridable in VB) member: {0}. - - - - - Allows setups to be specified for protected members by using their - name as a string, rather than strong-typing them which is not possible - due to their visibility. - - - - - Specifies a setup for a void method invocation with the given - , optionally specifying arguments for the method call. - - The name of the void method to be invoked. - The optional arguments for the invocation. If argument matchers are used, - remember to use rather than . - - - - Specifies a setup for an invocation on a property or a non void method with the given - , optionally specifying arguments for the method call. - - The name of the method or property to be invoked. - The optional arguments for the invocation. If argument matchers are used, - remember to use rather than . - The return type of the method or property. - - - - Specifies a setup for an invocation on a property getter with the given - . - - The name of the property. - The type of the property. - - - - Specifies a setup for an invocation on a property setter with the given - . - - The name of the property. - The property value. If argument matchers are used, - remember to use rather than . - The type of the property. - - - - Specifies a verify for a void method with the given , - optionally specifying arguments for the method call. Use in conjuntion with the default - . - - The invocation was not call the times specified by - . - The name of the void method to be verified. - The number of times a method is allowed to be called. - The optional arguments for the invocation. If argument matchers are used, - remember to use rather than . - - - - Specifies a verify for an invocation on a property or a non void method with the given - , optionally specifying arguments for the method call. - - The invocation was not call the times specified by - . - The name of the method or property to be invoked. - The optional arguments for the invocation. If argument matchers are used, - remember to use rather than . - The number of times a method is allowed to be called. - The type of return value from the expression. - - - - Specifies a verify for an invocation on a property getter with the given - . - The invocation was not call the times specified by - . - - The name of the property. - The number of times a method is allowed to be called. - The type of the property. - - - - Specifies a setup for an invocation on a property setter with the given - . - - The invocation was not call the times specified by - . - The name of the property. - The number of times a method is allowed to be called. - The property value. - The type of the property. If argument matchers are used, - remember to use rather than . - - - - Allows the specification of a matching condition for an - argument in a protected member setup, rather than a specific - argument value. "ItExpr" refers to the argument being matched. - - - Use this variant of argument matching instead of - for protected setups. - This class allows the setup to match a method invocation - with an arbitrary value, with a value in a specified range, or - even one that matches a given predicate, or null. - - - - - Matches a null value of the given type. - - - Required for protected mocks as the null value cannot be used - directly as it prevents proper method overload selection. - - - - // Throws an exception for a call to Remove with a null string value. - mock.Protected() - .Setup("Remove", ItExpr.IsNull<string>()) - .Throws(new InvalidOperationException()); - - - Type of the value. - - - - Matches any value of the given type. - - - Typically used when the actual argument value for a method - call is not relevant. - - - - // Throws an exception for a call to Remove with any string value. - mock.Protected() - .Setup("Remove", ItExpr.IsAny<string>()) - .Throws(new InvalidOperationException()); - - - Type of the value. - - - - Matches any value that satisfies the given predicate. - - Type of the argument to check. - The predicate used to match the method argument. - - Allows the specification of a predicate to perform matching - of method call arguments. - - - This example shows how to return the value 1 whenever the argument to the - Do method is an even number. - - mock.Protected() - .Setup("Do", ItExpr.Is<int>(i => i % 2 == 0)) - .Returns(1); - - This example shows how to throw an exception if the argument to the - method is a negative number: - - mock.Protected() - .Setup("GetUser", ItExpr.Is<int>(i => i < 0)) - .Throws(new ArgumentException()); - - - - - - Matches any value that is in the range specified. - - Type of the argument to check. - The lower bound of the range. - The upper bound of the range. - The kind of range. See . - - The following example shows how to expect a method call - with an integer argument within the 0..100 range. - - mock.Protected() - .Setup("HasInventory", - ItExpr.IsAny<string>(), - ItExpr.IsInRange(0, 100, Range.Inclusive)) - .Returns(false); - - - - - - Matches a string argument if it matches the given regular expression pattern. - - The pattern to use to match the string argument value. - - The following example shows how to expect a call to a method where the - string argument matches the given regular expression: - - mock.Protected() - .Setup("Check", ItExpr.IsRegex("[a-z]+")) - .Returns(1); - - - - - - Matches a string argument if it matches the given regular expression pattern. - - The pattern to use to match the string argument value. - The options used to interpret the pattern. - - The following example shows how to expect a call to a method where the - string argument matches the given regular expression, in a case insensitive way: - - mock.Protected() - .Setup("Check", ItExpr.IsRegex("[a-z]+", RegexOptions.IgnoreCase)) - .Returns(1); - - - - - - Enables the Protected() method on , - allowing setups to be set for protected members by using their - name as a string, rather than strong-typing them which is not possible - due to their visibility. - - - - - Enable protected setups for the mock. - - Mocked object type. Typically omitted as it can be inferred from the mock instance. - The mock to set the protected setups on. - - - - - - - - - - - - Kind of range to use in a filter specified through - . - - - - - The range includes the to and - from values. - - - - - The range does not include the to and - from values. - - - - - Determines the way default values are generated - calculated for loose mocks. - - - - - Default behavior, which generates empty values for - value types (i.e. default(int)), empty array and - enumerables, and nulls for all other reference types. - - - - - Whenever the default value generated by - is null, replaces this value with a mock (if the type - can be mocked). - - - For sealed classes, a null value will be generated. - - - - - A default implementation of IQueryable for use with QueryProvider - - - - - The is a - static method that returns an IQueryable of Mocks of T which is used to - apply the linq specification to. - - - - - Allows creation custom value matchers that can be used on setups and verification, - completely replacing the built-in class with your own argument - matching rules. - - See also . - - - - - Provided for the sole purpose of rendering the delegate passed to the - matcher constructor if no friendly render lambda is provided. - - - - - Initializes the match with the condition that - will be checked in order to match invocation - values. - The condition to match against actual values. - - - - - - - - - This method is used to set an expression as the last matcher invoked, - which is used in the SetupSet to allow matchers in the prop = value - delegate expression. This delegate is executed in "fluent" mode in - order to capture the value being set, and construct the corresponding - methodcall. - This is also used in the MatcherFactory for each argument expression. - This method ensures that when we execute the delegate, we - also track the matcher that was invoked, so that when we create the - methodcall we build the expression using it, rather than the null/default - value returned from the actual invocation. - - - - - Allows creation custom value matchers that can be used on setups and verification, - completely replacing the built-in class with your own argument - matching rules. - Type of the value to match. - The argument matching is used to determine whether a concrete - invocation in the mock matches a given setup. This - matching mechanism is fully extensible. - - Creating a custom matcher is straightforward. You just need to create a method - that returns a value from a call to with - your matching condition and optional friendly render expression: - - [Matcher] - public Order IsBigOrder() - { - return Match<Order>.Create( - o => o.GrandTotal >= 5000, - /* a friendly expression to render on failures */ - () => IsBigOrder()); - } - - This method can be used in any mock setup invocation: - - mock.Setup(m => m.Submit(IsBigOrder()).Throws<UnauthorizedAccessException>(); - - At runtime, Moq knows that the return value was a matcher (note that the method MUST be - annotated with the [Matcher] attribute in order to determine this) and - evaluates your predicate with the actual value passed into your predicate. - - Another example might be a case where you want to match a lists of orders - that contains a particular one. You might create matcher like the following: - - - public static class Orders - { - [Matcher] - public static IEnumerable<Order> Contains(Order order) - { - return Match<IEnumerable<Order>>.Create(orders => orders.Contains(order)); - } - } - - Now we can invoke this static method instead of an argument in an - invocation: - - var order = new Order { ... }; - var mock = new Mock<IRepository<Order>>(); - - mock.Setup(x => x.Save(Orders.Contains(order))) - .Throws<ArgumentException>(); - - - - - - Tracks the current mock and interception context. - - - - - Having an active fluent mock context means that the invocation - is being performed in "trial" mode, just to gather the - target method and arguments that need to be matched later - when the actual invocation is made. - - - - - A that returns an empty default value - for non-mockeable types, and mocks for all other types (interfaces and - non-sealed classes) that can be mocked. - - - - - Allows querying the universe of mocks for those that behave - according to the LINQ query specification. - - - This entry-point into Linq to Mocks is the only one in the root Moq - namespace to ease discovery. But to get all the mocking extension - methods on Object, a using of Moq.Linq must be done, so that the - polluting of the intellisense for all objects is an explicit opt-in. - - - - - Access the universe of mocks of the given type, to retrieve those - that behave according to the LINQ query specification. - - The type of the mocked object to query. - - - - Access the universe of mocks of the given type, to retrieve those - that behave according to the LINQ query specification. - - The predicate with the setup expressions. - The type of the mocked object to query. - - - - Creates an mock object of the indicated type. - - The type of the mocked object. - The mocked object created. - - - - Creates an mock object of the indicated type. - - The predicate with the setup expressions. - The type of the mocked object. - The mocked object created. - - - - Creates the mock query with the underlying queriable implementation. - - - - - Wraps the enumerator inside a queryable. - - - - - Method that is turned into the actual call from .Query{T}, to - transform the queryable query into a normal enumerable query. - This method is never used directly by consumers. - - - - - Extension method used to support Linq-like setup properties that are not virtual but do have - a getter and a setter, thereby allowing the use of Linq to Mocks to quickly initialize Dtos too :) - - - - - Helper extensions that are used by the query translator. - - - - - Retrieves a fluent mock from the given setup expression. - - - - - Gets an autogenerated interface with a method on it that matches the signature of the specified - . - - - Such an interface can then be mocked, and a delegate pointed at the method on the mocked instance. - This is how we support delegate mocking. The factory caches such interfaces and reuses them - for repeated requests for the same delegate type. - - The delegate type for which an interface is required. - The method on the autogenerated interface. - - - - - - - - - - Defines the number of invocations allowed by a mocked method. - - - - - Specifies that a mocked method should be invoked times as minimum. - The minimun number of times.An object defining the allowed number of invocations. - - - - Specifies that a mocked method should be invoked one time as minimum. - An object defining the allowed number of invocations. - - - - Specifies that a mocked method should be invoked time as maximun. - The maximun number of times.An object defining the allowed number of invocations. - - - - Specifies that a mocked method should be invoked one time as maximun. - An object defining the allowed number of invocations. - - - - Specifies that a mocked method should be invoked between and - times. - The minimun number of times.The maximun number of times. - The kind of range. See . - An object defining the allowed number of invocations. - - - - Specifies that a mocked method should be invoked exactly times. - The times that a method or property can be called.An object defining the allowed number of invocations. - - - - Specifies that a mocked method should not be invoked. - An object defining the allowed number of invocations. - - - - Specifies that a mocked method should be invoked exactly one time. - An object defining the allowed number of invocations. - - - - Determines whether the specified is equal to this instance. - - The to compare with this instance. - - true if the specified is equal to this instance; otherwise, false. - - - - - Returns a hash code for this instance. - - A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - - - - - Determines whether two specified objects have the same value. - - The first . - - The second . - - true if the value of left is the same as the value of right; otherwise, false. - - - - - Determines whether two specified objects have different values. - - The first . - - The second . - - true if the value of left is different from the value of right; otherwise, false. - - - - diff --git a/Lib/NativeBinaries/amd64/git2-4a30c53.dll b/Lib/NativeBinaries/amd64/git2-4a30c53.dll deleted file mode 100644 index 88284d8dc..000000000 Binary files a/Lib/NativeBinaries/amd64/git2-4a30c53.dll and /dev/null differ diff --git a/Lib/NativeBinaries/amd64/git2-e0902fb.dll b/Lib/NativeBinaries/amd64/git2-e0902fb.dll new file mode 100644 index 000000000..f4931dbdd Binary files /dev/null and b/Lib/NativeBinaries/amd64/git2-e0902fb.dll differ diff --git a/Lib/NativeBinaries/amd64/git2-4a30c53.pdb b/Lib/NativeBinaries/amd64/git2-e0902fb.pdb similarity index 51% rename from Lib/NativeBinaries/amd64/git2-4a30c53.pdb rename to Lib/NativeBinaries/amd64/git2-e0902fb.pdb index 70d17739f..bdef63b09 100644 Binary files a/Lib/NativeBinaries/amd64/git2-4a30c53.pdb and b/Lib/NativeBinaries/amd64/git2-e0902fb.pdb differ diff --git a/Lib/NativeBinaries/x86/git2-4a30c53.dll b/Lib/NativeBinaries/x86/git2-4a30c53.dll deleted file mode 100644 index 0a4fd975d..000000000 Binary files a/Lib/NativeBinaries/x86/git2-4a30c53.dll and /dev/null differ diff --git a/Lib/NativeBinaries/x86/git2-e0902fb.dll b/Lib/NativeBinaries/x86/git2-e0902fb.dll new file mode 100644 index 000000000..b0c55e6cf Binary files /dev/null and b/Lib/NativeBinaries/x86/git2-e0902fb.dll differ diff --git a/Lib/NativeBinaries/x86/git2-4a30c53.pdb b/Lib/NativeBinaries/x86/git2-e0902fb.pdb similarity index 53% rename from Lib/NativeBinaries/x86/git2-4a30c53.pdb rename to Lib/NativeBinaries/x86/git2-e0902fb.pdb index 207a61b77..d466f239a 100644 Binary files a/Lib/NativeBinaries/x86/git2-4a30c53.pdb and b/Lib/NativeBinaries/x86/git2-e0902fb.pdb differ diff --git a/Lib/NuGet/NuGet.exe b/Lib/NuGet/NuGet.exe index cb3ed0367..ed2b0a221 100644 Binary files a/Lib/NuGet/NuGet.exe and b/Lib/NuGet/NuGet.exe differ diff --git a/Lib/xUnit/xUnit.license.txt b/Lib/xUnit/xUnit.license.txt deleted file mode 100644 index 48715cacc..000000000 --- a/Lib/xUnit/xUnit.license.txt +++ /dev/null @@ -1,29 +0,0 @@ -This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software. - -1. Definitions - -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law. - -A "contribution" is the original software, or any additions or changes to the software. - -A "contributor" is any person that distributes its contribution under this license. - -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights - -(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. - -(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. - -3. Conditions and Limitations - -(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. - -(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. - -(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. - -(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. - -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. diff --git a/Lib/xUnit/xunit.dll b/Lib/xUnit/xunit.dll deleted file mode 100644 index 86168af53..000000000 Binary files a/Lib/xUnit/xunit.dll and /dev/null differ diff --git a/Lib/xUnit/xunit.dll.tdnet b/Lib/xUnit/xunit.dll.tdnet deleted file mode 100644 index d14ca810f..000000000 --- a/Lib/xUnit/xunit.dll.tdnet +++ /dev/null @@ -1,5 +0,0 @@ - - xUnit.net {0}.{1}.{2} build {3} - xunit.runner.tdnet.dll - Xunit.Runner.TdNet.TdNetRunner - \ No newline at end of file diff --git a/Lib/xUnit/xunit.extensions.dll b/Lib/xUnit/xunit.extensions.dll deleted file mode 100644 index 0b1907e63..000000000 Binary files a/Lib/xUnit/xunit.extensions.dll and /dev/null differ diff --git a/Lib/xUnit/xunit.extensions.xml b/Lib/xUnit/xunit.extensions.xml deleted file mode 100644 index 7434835a5..000000000 --- a/Lib/xUnit/xunit.extensions.xml +++ /dev/null @@ -1,805 +0,0 @@ - - - - xunit.extensions - - - - - A wrapper for Assert which is used by . - - - - - Verifies that a collection contains a given object. - - The type of the object to be verified - The object expected to be in the collection - The collection to be inspected - Thrown when the object is not present in the collection - - - - Verifies that a collection contains a given object, using an equality comparer. - - The type of the object to be verified - The object expected to be in the collection - The collection to be inspected - The comparer used to equate objects in the collection with the expected object - Thrown when the object is not present in the collection - - - - Verifies that a string contains a given sub-string, using the current culture. - - The sub-string expected to be in the string - The string to be inspected - Thrown when the sub-string is not present inside the string - - - - Verifies that a string contains a given sub-string, using the given comparison type. - - The sub-string expected to be in the string - The string to be inspected - The type of string comparison to perform - Thrown when the sub-string is not present inside the string - - - - Verifies that a collection does not contain a given object. - - The type of the object to be compared - The object that is expected not to be in the collection - The collection to be inspected - Thrown when the object is present inside the container - - - - Verifies that a collection does not contain a given object, using an equality comparer. - - The type of the object to be compared - The object that is expected not to be in the collection - The collection to be inspected - The comparer used to equate objects in the collection with the expected object - Thrown when the object is present inside the container - - - - Verifies that a string does not contain a given sub-string, using the current culture. - - The sub-string which is expected not to be in the string - The string to be inspected - Thrown when the sub-string is present inside the string - - - - Verifies that a string does not contain a given sub-string, using the current culture. - - The sub-string which is expected not to be in the string - The string to be inspected - The type of string comparison to perform - Thrown when the sub-string is present inside the given string - - - - Verifies that a block of code does not throw any exceptions. - - A delegate to the code to be tested - - - - Verifies that a collection is empty. - - The collection to be inspected - Thrown when the collection is null - Thrown when the collection is not empty - - - - Verifies that two objects are equal, using a default comparer. - - The type of the objects to be compared - The expected value - The value to be compared against - Thrown when the objects are not equal - - - - Verifies that two objects are equal, using a custom equatable comparer. - - The type of the objects to be compared - The expected value - The value to be compared against - The comparer used to compare the two objects - Thrown when the objects are not equal - - - - Verifies that two values are equal, within the number of decimal - places given by . - - The expected value - The value to be compared against - The number of decimal places (valid values: 0-15) - Thrown when the values are not equal - - - - Verifies that two values are equal, within the number of decimal - places given by . - - The expected value - The value to be compared against - The number of decimal places (valid values: 0-15) - Thrown when the values are not equal - - - - Verifies that the condition is false. - - The condition to be tested - Thrown if the condition is not false - - - - Verifies that the condition is false. - - The condition to be tested - The message to show when the condition is not false - Thrown if the condition is not false - - - - Verifies that a value is within a given range. - - The type of the value to be compared - The actual value to be evaluated - The (inclusive) low value of the range - The (inclusive) high value of the range - Thrown when the value is not in the given range - - - - Verifies that a value is within a given range, using a comparer. - - The type of the value to be compared - The actual value to be evaluated - The (inclusive) low value of the range - The (inclusive) high value of the range - The comparer used to evaluate the value's range - Thrown when the value is not in the given range - - - - Verifies that an object is of the given type or a derived type. - - The type the object should be - The object to be evaluated - The object, casted to type T when successful - Thrown when the object is not the given type - - - - Verifies that an object is of the given type or a derived type. - - The type the object should be - The object to be evaluated - Thrown when the object is not the given type - - - - Verifies that an object is not exactly the given type. - - The type the object should not be - The object to be evaluated - Thrown when the object is the given type - - - - Verifies that an object is not exactly the given type. - - The type the object should not be - The object to be evaluated - Thrown when the object is the given type - - - - Verifies that an object is exactly the given type (and not a derived type). - - The type the object should be - The object to be evaluated - The object, casted to type T when successful - Thrown when the object is not the given type - - - - Verifies that an object is exactly the given type (and not a derived type). - - The type the object should be - The object to be evaluated - Thrown when the object is not the given type - - - - Verifies that a collection is not empty. - - The collection to be inspected - Thrown when a null collection is passed - Thrown when the collection is empty - - - - Verifies that two objects are not equal, using a default comparer. - - The type of the objects to be compared - The expected object - The actual object - Thrown when the objects are equal - - - - Verifies that two objects are not equal, using a custom equality comparer. - - The type of the objects to be compared - The expected object - The actual object - The comparer used to examine the objects - Thrown when the objects are equal - - - - Verifies that a value is not within a given range, using the default comparer. - - The type of the value to be compared - The actual value to be evaluated - The (inclusive) low value of the range - The (inclusive) high value of the range - Thrown when the value is in the given range - - - - Verifies that a value is not within a given range, using a comparer. - - The type of the value to be compared - The actual value to be evaluated - The (inclusive) low value of the range - The (inclusive) high value of the range - The comparer used to evaluate the value's range - Thrown when the value is in the given range - - - - Verifies that an object reference is not null. - - The object to be validated - Thrown when the object is not null - - - - Verifies that two objects are not the same instance. - - The expected object instance - The actual object instance - Thrown when the objects are the same instance - - - - Verifies that an object reference is null. - - The object to be inspected - Thrown when the object reference is not null - - - - Verifies that two objects are the same instance. - - The expected object instance - The actual object instance - Thrown when the objects are not the same instance - - - - Verifies that the given collection contains only a single - element of the given type. - - The collection. - The single item in the collection. - Thrown when the collection does not contain - exactly one element. - - - - Verifies that the given collection contains only a single - element of the given type. - - The collection type. - The collection. - The single item in the collection. - Thrown when the collection does not contain - exactly one element. - - - - Verifies that the exact exception is thrown (and not a derived exception type). - - The type of the exception expected to be thrown - A delegate to the code to be tested - The exception that was thrown, when successful - Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - - - - Verifies that the exact exception is thrown (and not a derived exception type). - Generally used to test property accessors. - - The type of the exception expected to be thrown - A delegate to the code to be tested - The exception that was thrown, when successful - Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - - - - Verifies that the exact exception is thrown (and not a derived exception type). - - The type of the exception expected to be thrown - A delegate to the code to be tested - The exception that was thrown, when successful - Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - - - - Verifies that the exact exception is thrown (and not a derived exception type). - Generally used to test property accessors. - - The type of the exception expected to be thrown - A delegate to the code to be tested - The exception that was thrown, when successful - Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - - - - Verifies that an expression is true. - - The condition to be inspected - Thrown when the condition is false - - - - Verifies that an expression is true. - - The condition to be inspected - The message to be shown when the condition is false - Thrown when the condition is false - - - - A class which can be derived from for test classes, which bring an overridable version - of Assert (using the class. - - - - - Gets a class which provides assertions. - - - - - Apply this attribute to your test method to replace the - with another role. - - - - - Replaces the identity of the current thread with . - - The role's name - - - - Restores the original . - - The method under test - - - - Stores the current and replaces it with - a new role identified in constructor. - - The method under test - - - - Gets the name. - - - - - Apply this attribute to your test method to automatically create a - that is rolled back when the test is - finished. - - - - - Rolls back the transaction. - - - - - Creates the transaction. - - - - - Gets or sets the isolation level of the transaction. - Default value is .Unspecified. - - - - - Gets or sets the scope option for the transaction. - Default value is .Required. - - - - - Gets or sets the timeout of the transaction, in milliseconds. - By default, the transaction will not timeout. - - - - - Provides a data source for a data theory, with the data coming from a class - which must implement IEnumerable<object[]>. - - - - - Abstract attribute which represents a data source for a data theory. - Data source providers derive from this attribute and implement GetData - to return the data for the theory. - - - - - Returns the data to be used to test the theory. - - - The parameter is provided so that the - test data can be converted to the destination parameter type when necessary. - Generally, data should NOT be automatically converted, UNLESS the source data - format does not have rich types (for example, all numbers in Excel spreadsheets - are returned as even if they are integers). Derivers of - this class should NOT throw exceptions for mismatched types or mismatched number - of parameters; the test framework will throw these exceptions at the correct - time. - - The method that is being tested - The types of the parameters for the test method - The theory data - - - - - - - Initializes a new instance of the class. - - The class that provides the data. - - - - - - - Gets the type of the class that provides the data. - - - - - Represents an implementation of which uses an - instance of to get the data for a - decorated test method. - - - - - - - - Converts a parameter to its destination parameter type, if necessary. - - The parameter value - The destination parameter type (null if not known) - The converted parameter value - - - - Gets the data adapter to be used to retrieve the test data. - - - - - Provides a data source for a data theory, with the data coming from inline values. - - - - - Initializes a new instance of the class. - - The data values to pass to the theory - - - - Returns the data to be used to test the theory. - - The method that is being tested - The types of the parameters for the test method - The theory data, in table form - - - - Gets the data values. - - - - - Provides a data source for a data theory, with the data coming from an OLEDB connection. - - - - - Creates a new instance of . - - The OLEDB connection string to the data - The SELECT statement used to return the data for the theory - - - - Gets the connection string. - - - - - Gets the select statement. - - - - - - - - Provides a data source for a data theory, with the data coming from a public static property on the test class. - The property must return IEnumerable<object[]> with the test data. - - - - - Creates a new instance of / - - The name of the public static property on the test class that will provide the test data - - - - Returns the data to be used to test the theory. - - The method that is being tested - The types of the parameters for the test method - The theory data, in table form - - - - Gets the property name. - - - - - Provides a data source for a data theory, with the data coming a Microsoft SQL Server. - - - - - Creates a new instance of , using a trusted connection. - - The server name of the Microsoft SQL Server - The database name - The SQL SELECT statement to return the data for the data theory - - - - Creates a new instance of , using the provided username and password. - - The server name of the Microsoft SQL Server - The database name - The username for the server - The password for the server - The SQL SELECT statement to return the data for the data theory - - - - Provides a data source for a data theory, with the data coming a Microsoft Excel (.xls) spreadsheet. - - - - - Creates a new instance of . - - The filename of the XLS spreadsheet file; if the filename provided - is relative, then it is relative to the location of xunit.extensions.dll. - The SELECT statement that returns the data for the theory - - - - - - - A wrapper around the static operations on which allows time - to be frozen using the . The clock begins in the - thawed state; that is, calls to , , and - return current (non-frozen) values. - - - - - Freezes the clock with the current time. - Until is called, all calls to , , and - will return the exact same values. - - - - - Freezes the clock with the given date and time, considered to be local time. - Until is called, all calls to , , and - will return the exact same values. - - The local date and time to freeze to - - - - Freezes the clock with the given date and time, considered to be Coordinated Universal Time (UTC). - Until is called, all calls to , , and - will return the exact same values. - - The UTC date and time to freeze to - - - - Thaws the clock so that , , and - return normal values. - - - - - Gets a object that is set to the current date and time on this computer, - expressed as the local time. - - - - - Gets the current date. - - - - - Gets a object that is set to the current date and time on this computer, - expressed as the Coordinated Universal Time (UTC). - - - - - Apply this attribute to your test method to freeze the time represented by the - class. - - - - - Freeze the clock with the current date and time. - - - - - Freeze the clock with the given date, considered to be local time. - - The frozen year - The frozen month - The frozen day - - - - Freeze the clock with the given date and time, considered to be in local time. - - The frozen year - The frozen month - The frozen day - The frozen hour - The frozen minute - The frozen second - - - - Freeze the clock with the given date and time, with the given kind of time. - - The frozen year - The frozen month - The frozen day - The frozen hour - The frozen minute - The frozen second - The frozen time kind - - - - Thaws the clock. - - The method under test - - - - Freezes the clock. - - The method under test - - - - Marks a test method as being a data theory. Data theories are tests which are fed - various bits of data from a data source, mapping to parameters on the test method. - If the data source contains multiple rows, then the test method is executed - multiple times (once with each data row). - - - - - Creates instances of which represent individual intended - invocations of the test method, one per data row in the data source. - - The method under test - An enumerator through the desired test method invocations - - - - Represents a single invocation of a data theory test method. - - - - - Creates a new instance of . - - The method under test - The parameters to be passed to the test method - - - - Creates a new instance of based on a generic theory. - - The method under test - The parameters to be passed to the test method - The generic types that were used to resolved the generic method. - - - - - - - Gets the parameter values that are passed to the test method. - - - - - Apply to a test method to trace the method begin and end. - - - - - This method is called before the test method is executed. - - The method under test - - - - This method is called after the test method is executed. - - The method under test - - - diff --git a/Lib/xUnit/xunit.runner.msbuild.dll b/Lib/xUnit/xunit.runner.msbuild.dll deleted file mode 100644 index ac2065d02..000000000 Binary files a/Lib/xUnit/xunit.runner.msbuild.dll and /dev/null differ diff --git a/Lib/xUnit/xunit.runner.tdnet.dll b/Lib/xUnit/xunit.runner.tdnet.dll deleted file mode 100644 index f7d0639ae..000000000 Binary files a/Lib/xUnit/xunit.runner.tdnet.dll and /dev/null differ diff --git a/Lib/xUnit/xunit.runner.utility.dll b/Lib/xUnit/xunit.runner.utility.dll deleted file mode 100644 index cc1f21bf8..000000000 Binary files a/Lib/xUnit/xunit.runner.utility.dll and /dev/null differ diff --git a/Lib/xUnit/xunit.xml b/Lib/xUnit/xunit.xml deleted file mode 100644 index 4b60b4400..000000000 --- a/Lib/xUnit/xunit.xml +++ /dev/null @@ -1,2604 +0,0 @@ - - - - xunit - - - - - Contains various static methods that are used to verify that conditions are met during the - process of running tests. - - - - - Initializes a new instance of the class. - - - - - Verifies that a collection contains a given object. - - The type of the object to be verified - The object expected to be in the collection - The collection to be inspected - Thrown when the object is not present in the collection - - - - Verifies that a collection contains a given object, using an equality comparer. - - The type of the object to be verified - The object expected to be in the collection - The collection to be inspected - The comparer used to equate objects in the collection with the expected object - Thrown when the object is not present in the collection - - - - Verifies that a string contains a given sub-string, using the current culture. - - The sub-string expected to be in the string - The string to be inspected - Thrown when the sub-string is not present inside the string - - - - Verifies that a string contains a given sub-string, using the given comparison type. - - The sub-string expected to be in the string - The string to be inspected - The type of string comparison to perform - Thrown when the sub-string is not present inside the string - - - - Verifies that a collection does not contain a given object. - - The type of the object to be compared - The object that is expected not to be in the collection - The collection to be inspected - Thrown when the object is present inside the container - - - - Verifies that a collection does not contain a given object, using an equality comparer. - - The type of the object to be compared - The object that is expected not to be in the collection - The collection to be inspected - The comparer used to equate objects in the collection with the expected object - Thrown when the object is present inside the container - - - - Verifies that a string does not contain a given sub-string, using the current culture. - - The sub-string which is expected not to be in the string - The string to be inspected - Thrown when the sub-string is present inside the string - - - - Verifies that a string does not contain a given sub-string, using the current culture. - - The sub-string which is expected not to be in the string - The string to be inspected - The type of string comparison to perform - Thrown when the sub-string is present inside the given string - - - - Verifies that a block of code does not throw any exceptions. - - A delegate to the code to be tested - - - - Verifies that a collection is empty. - - The collection to be inspected - Thrown when the collection is null - Thrown when the collection is not empty - - - - Verifies that two objects are equal, using a default comparer. - - The type of the objects to be compared - The expected value - The value to be compared against - Thrown when the objects are not equal - - - - Verifies that two objects are equal, using a custom equatable comparer. - - The type of the objects to be compared - The expected value - The value to be compared against - The comparer used to compare the two objects - Thrown when the objects are not equal - - - - Verifies that two values are equal, within the number of decimal - places given by . - - The expected value - The value to be compared against - The number of decimal places (valid values: 0-15) - Thrown when the values are not equal - - - - Verifies that two values are equal, within the number of decimal - places given by . - - The expected value - The value to be compared against - The number of decimal places (valid values: 0-15) - Thrown when the values are not equal - - - - Verifies that two sequences are equivalent, using a default comparer. - - The type of the objects to be compared - The expected value - The value to be compared against - Thrown when the objects are not equal - - - - Verifies that two sequences are equivalent, using a custom equatable comparer. - - The type of the objects to be compared - The expected value - The value to be compared against - The comparer used to compare the two objects - Thrown when the objects are not equal - - - Do not call this method. - - - - Verifies that the condition is false. - - The condition to be tested - Thrown if the condition is not false - - - - Verifies that the condition is false. - - The condition to be tested - The message to show when the condition is not false - Thrown if the condition is not false - - - - Verifies that a value is within a given range. - - The type of the value to be compared - The actual value to be evaluated - The (inclusive) low value of the range - The (inclusive) high value of the range - Thrown when the value is not in the given range - - - - Verifies that a value is within a given range, using a comparer. - - The type of the value to be compared - The actual value to be evaluated - The (inclusive) low value of the range - The (inclusive) high value of the range - The comparer used to evaluate the value's range - Thrown when the value is not in the given range - - - - Verifies that an object is of the given type or a derived type. - - The type the object should be - The object to be evaluated - The object, casted to type T when successful - Thrown when the object is not the given type - - - - Verifies that an object is of the given type or a derived type. - - The type the object should be - The object to be evaluated - Thrown when the object is not the given type - - - - Verifies that an object is not exactly the given type. - - The type the object should not be - The object to be evaluated - Thrown when the object is the given type - - - - Verifies that an object is not exactly the given type. - - The type the object should not be - The object to be evaluated - Thrown when the object is the given type - - - - Verifies that an object is exactly the given type (and not a derived type). - - The type the object should be - The object to be evaluated - The object, casted to type T when successful - Thrown when the object is not the given type - - - - Verifies that an object is exactly the given type (and not a derived type). - - The type the object should be - The object to be evaluated - Thrown when the object is not the given type - - - - Verifies that a collection is not empty. - - The collection to be inspected - Thrown when a null collection is passed - Thrown when the collection is empty - - - - Verifies that two objects are not equal, using a default comparer. - - The type of the objects to be compared - The expected object - The actual object - Thrown when the objects are equal - - - - Verifies that two objects are not equal, using a custom equality comparer. - - The type of the objects to be compared - The expected object - The actual object - The comparer used to examine the objects - Thrown when the objects are equal - - - - Verifies that two sequences are not equivalent, using a default comparer. - - The type of the objects to be compared - The expected object - The actual object - Thrown when the objects are equal - - - - Verifies that two sequences are not equivalent, using a custom equality comparer. - - The type of the objects to be compared - The expected object - The actual object - The comparer used to compare the two objects - Thrown when the objects are equal - - - - Verifies that a value is not within a given range, using the default comparer. - - The type of the value to be compared - The actual value to be evaluated - The (inclusive) low value of the range - The (inclusive) high value of the range - Thrown when the value is in the given range - - - - Verifies that a value is not within a given range, using a comparer. - - The type of the value to be compared - The actual value to be evaluated - The (inclusive) low value of the range - The (inclusive) high value of the range - The comparer used to evaluate the value's range - Thrown when the value is in the given range - - - - Verifies that an object reference is not null. - - The object to be validated - Thrown when the object is not null - - - - Verifies that two objects are not the same instance. - - The expected object instance - The actual object instance - Thrown when the objects are the same instance - - - - Verifies that an object reference is null. - - The object to be inspected - Thrown when the object reference is not null - - - - Verifies that the provided object raised INotifyPropertyChanged.PropertyChanged - as a result of executing the given test code. - - The object which should raise the notification - The property name for which the notification should be raised - The test code which should cause the notification to be raised - Thrown when the notification is not raised - - - - Verifies that two objects are the same instance. - - The expected object instance - The actual object instance - Thrown when the objects are not the same instance - - - - Verifies that the given collection contains only a single - element of the given type. - - The collection. - The single item in the collection. - Thrown when the collection does not contain - exactly one element. - - - - Verifies that the given collection contains only a single - element of the given value. The collection may or may not - contain other values. - - The collection. - The value to find in the collection. - The single item in the collection. - Thrown when the collection does not contain - exactly one element. - - - - Verifies that the given collection contains only a single - element of the given type. - - The collection type. - The collection. - The single item in the collection. - Thrown when the collection does not contain - exactly one element. - - - - Verifies that the given collection contains only a single - element of the given type which matches the given predicate. The - collection may or may not contain other values which do not - match the given predicate. - - The collection type. - The collection. - The item matching predicate. - The single item in the filtered collection. - Thrown when the filtered collection does - not contain exactly one element. - - - - Verifies that the exact exception is thrown (and not a derived exception type). - - The type of the exception expected to be thrown - A delegate to the code to be tested - The exception that was thrown, when successful - Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - - - - Verifies that the exact exception is thrown (and not a derived exception type). - Generally used to test property accessors. - - The type of the exception expected to be thrown - A delegate to the code to be tested - The exception that was thrown, when successful - Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - - - - Verifies that the exact exception is thrown (and not a derived exception type). - - The type of the exception expected to be thrown - A delegate to the code to be tested - The exception that was thrown, when successful - Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - - - - Verifies that the exact exception is thrown (and not a derived exception type). - Generally used to test property accessors. - - The type of the exception expected to be thrown - A delegate to the code to be tested - The exception that was thrown, when successful - Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - - - - Verifies that an expression is true. - - The condition to be inspected - Thrown when the condition is false - - - - Verifies that an expression is true. - - The condition to be inspected - The message to be shown when the condition is false - Thrown when the condition is false - - - - Used by the PropertyChanged. - - - - - Used by the Throws and DoesNotThrow methods. - - - - - Used by the Throws and DoesNotThrow methods. - - - - - This command sets up the necessary trace listeners and standard - output/error listeners to capture Assert/Debug.Trace failures, - output to stdout/stderr, and Assert/Debug.Write text. It also - captures any exceptions that are thrown and packages them as - FailedResults, including the possibility that the configuration - file is messed up (which is exposed when we attempt to manipulate - the trace listener list). - - - - - Base class used by commands which delegate to inner commands. - - - - - Interface which represents the ability to invoke of a test method. - - - - - Executes the test method. - - The instance of the test class - Returns information about the test run - - - - Creates the start XML to be sent to the callback when the test is about to start - running. - - Return the of the start node, or null if the test - is known that it will not be running. - - - - Gets the display name of the test method. - - - - - Determines if the test runner infrastructure should create a new instance of the - test class before running the test. - - - - - Determines if the test should be limited to running a specific amount of time - before automatically failing. - - The timeout value, in milliseconds; if zero, the test will not have - a timeout. - - - - Creates a new instance of the class. - - The inner command to delegate to. - - - - - - - - - - - - - - - - - - - - - - Initializes a new instance of the - class. - - The command that will be wrapped. - The test method. - - - - - - - Represents an implementation of to be used with - tests which are decorated with the . - - - - - Represents an xUnit.net test command. - - - - - The method under test. - - - - - Initializes a new instance of the class. - - The method under test. - The display name of the test. - The timeout, in milliseconds. - - - - - - - - - - - - - Gets the name of the method under test. - - - - - - - - - - - Gets the name of the type under test. - - - - - Initializes a new instance of the class. - - The test method. - - - - - - - Base class for exceptions that have actual and expected values - - - - - The base assert exception class - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The user message to be displayed - - - - Initializes a new instance of the class. - - The user message to be displayed - The inner exception - - - - Initializes a new instance of the class. - - The user message to be displayed - The stack trace to be displayed - - - - - - - Determines whether to exclude a line from the stack frame. By default, this method - removes all stack frames from methods beginning with Xunit.Assert or Xunit.Sdk. - - The stack frame to be filtered. - Return true to exclude the line from the stack frame; false, otherwise. - - - - Filters the stack trace to remove all lines that occur within the testing framework. - - The original stack trace - The filtered stack trace - - - - - - - Gets a string representation of the frames on the call stack at the time the current exception was thrown. - - A string that describes the contents of the call stack, with the most recent method call appearing first. - - - - Gets the user message - - - - - Creates a new instance of the class. - - The expected value - The actual value - The user message to be shown - - - - Creates a new instance of the class. - - The expected value - The actual value - The user message to be shown - Set to true to skip the check for difference position - - - - - - - - - - Gets the actual value. - - - - - Gets the expected value. - - - - - Gets a message that describes the current exception. Includes the expected and actual values. - - The error message that explains the reason for the exception, or an empty string(""). - 1 - - - - Exception thrown when a collection unexpectedly does not contain the expected value. - - - - - Creates a new instance of the class. - - The expected object value - - - - Creates a new instance of the class. - - The expected object value - The actual value - - - - - - - Exception to be thrown from when the number of - parameter values does not the test method signature. - - - - - - - - - - - Exception thrown when code unexpectedly fails change a property. - - - - - Creates a new instance of the class. Call this constructor - when no exception was thrown. - - The name of the property that was expected. - - - - - - - Exception thrown when the collection did not contain exactly one element. - - - - - Initializes a new instance of the class. - - The numbers of items in the collection. - - - - Initializes a new instance of the class. - - The numbers of items in the collection. - The object expected to be in the collection. - - - - - - - Internal class used for version-resilient test runners. DO NOT CALL DIRECTLY. - Version-resilient runners should link against xunit.runner.utility.dll and use - ExecutorWrapper instead. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Exception thrown when the value is unexpectedly not of the given type or a derived type. - - - - - Creates a new instance of the class. - - The expected type - The actual object value - - - - - - - Allows the user to record actions for a test. - - - - - Records any exception which is thrown by the given code. - - The code which may thrown an exception. - Returns the exception that was thrown by the code; null, otherwise. - - - - Records any exception which is thrown by the given code that has - a return value. Generally used for testing property accessors. - - The code which may thrown an exception. - Returns the exception that was thrown by the code; null, otherwise. - - - - Exception that is thrown when one or more exceptions are thrown from - the After method of a . - - - - - Initializes a new instance of the class. - - The exceptions. - - - - Initializes a new instance of the class. - - The exceptions. - - - - - - - - - - Gets the list of exceptions thrown in the After method. - - - - - Gets a message that describes the current exception. - - - - - Gets a string representation of the frames on the call stack at the time the current exception was thrown. - - - - - Implementation of which executes the - instances attached to a test method. - - - - - Initializes a new instance of the class. - - The inner command. - The method. - - - - Executes the test method. - - The instance of the test class - Returns information about the test run - - - - This class supports the xUnit.net infrastructure and is not intended to be used - directly from your code. - - - - - This API supports the xUnit.net infrastructure and is not intended to be used - directly from your code. - - - - - This API supports the xUnit.net infrastructure and is not intended to be used - directly from your code. - - - - - This API supports the xUnit.net infrastructure and is not intended to be used - directly from your code. - - - - - Guard class, used for guard clauses and argument validation - - - - - - - - - - - - - - Base class which contains XML manipulation helper methods - - - - - Interface that represents a single test result. - - - - - Converts the test result into XML that is consumed by the test runners. - - The parent node. - The newly created XML node. - - - - The amount of time spent in execution - - - - - Adds the test execution time to the XML node. - - The XML node. - - - - - - - - - - Utility methods for dealing with exceptions. - - - - - Gets the message for the exception, including any inner exception messages. - - The exception - The formatted message - - - - Gets the stack trace for the exception, including any inner exceptions. - - The exception - The formatted stack trace - - - - Rethrows an exception object without losing the existing stack trace information - - The exception to re-throw. - - For more information on this technique, see - http://www.dotnetjunkies.com/WebLog/chris.taylor/archive/2004/03/03/8353.aspx - - - - - A dictionary which contains multiple unique values for each key. - - The type of the key. - The type of the value. - - - - Adds the value for the given key. If the key does not exist in the - dictionary yet, it will add it. - - The key. - The value. - - - - Removes all keys and values from the dictionary. - - - - - Determines whether the dictionary contains to specified key and value. - - The key. - The value. - - - - Calls the delegate once for each key/value pair in the dictionary. - - - - - Removes the given key and all of its values. - - - - - Removes the given value from the given key. If this was the - last value for the key, then the key is removed as well. - - The key. - The value. - - - - Gets the values for the given key. - - - - - Gets the count of the keys in the dictionary. - - - - - Gets the keys. - - - - - - - - XML utility methods - - - - - Adds an attribute to an XML node. - - The XML node. - The attribute name. - The attribute value. - - - - Adds a child element to an XML node. - - The parent XML node. - The child element name. - The new child XML element. - - - - Exception that is thrown when a call to Debug.Assert() fails. - - - - - Creates a new instance of the class. - - The original assert message - - - - Creates a new instance of the class. - - The original assert message - The original assert detailed message - - - - - - - - - - Gets the original assert detailed message. - - - - - Gets the original assert message. - - - - - Gets a message that describes the current exception. - - - - - Exception thrown when a collection unexpectedly contains the expected value. - - - - - Creates a new instance of the class. - - The expected object value - - - - - - - Exception thrown when code unexpectedly throws an exception. - - - - - Creates a new instance of the class. - - Actual exception - - - - THIS CONSTRUCTOR IS FOR UNIT TESTING PURPOSES ONLY. - - - - - - - - - - - Gets a string representation of the frames on the call stack at the time the current exception was thrown. - - A string that describes the contents of the call stack, with the most recent method call appearing first. - - - - Exception thrown when a collection is unexpectedly not empty. - - - - - Creates a new instance of the class. - - - - - - - - Exception thrown when two values are unexpectedly not equal. - - - - - Creates a new instance of the class. - - The expected object value - The actual object value - - - - Creates a new instance of the class. - - The expected object value - The actual object value - Set to true to skip the check for difference position - - - - - - - Exception thrown when a value is unexpectedly true. - - - - - Creates a new instance of the class. - - The user message to be display, or null for the default message - - - - - - - Exception thrown when a value is unexpectedly not in the given range. - - - - - Creates a new instance of the class. - - The actual object value - The low value of the range - The high value of the range - - - - - - - - - - Gets the actual object value - - - - - Gets the high value of the range - - - - - Gets the low value of the range - - - - - Gets a message that describes the current exception. - - The error message that explains the reason for the exception, or an empty string(""). - - - - Exception thrown when the value is unexpectedly of the exact given type. - - - - - Creates a new instance of the class. - - The expected type - The actual object value - - - - - - - Exception thrown when the value is unexpectedly not of the exact given type. - - - - - Creates a new instance of the class. - - The expected type - The actual object value - - - - - - - Used to decorate xUnit.net test classes that utilize fixture classes. - An instance of the fixture data is initialized just before the first - test in the class is run, and if it implements IDisposable, is disposed - after the last test in the class is run. - - The type of the fixture - - - - Called on the test class just before each test method is run, - passing the fixture data so that it can be used for the test. - All test runs share the same instance of fixture data. - - The fixture data - - - - Exception thrown when a value is unexpectedly in the given range. - - - - - Creates a new instance of the class. - - The actual object value - The low value of the range - The high value of the range - - - - - - - - - - Gets the actual object value - - - - - Gets the high value of the range - - - - - Gets the low value of the range - - - - - Gets a message that describes the current exception. - - The error message that explains the reason for the exception, or an empty string(""). - - - - Base attribute which indicates a test method interception (allows code to be run before and - after the test is run). - - - - - This method is called after the test method is executed. - - The method under test - - - - This method is called before the test method is executed. - - The method under test - - - - - - - Exception thrown when a collection is unexpectedly empty. - - - - - Creates a new instance of the class. - - - - - - - - Exception thrown when two values are unexpectedly equal. - - - - - Creates a new instance of the class. - - - - - - - - Exception thrown when an object is unexpectedly null. - - - - - Creates a new instance of the class. - - - - - - - - Exception thrown when two values are unexpected the same instance. - - - - - Creates a new instance of the class. - - - - - - - - Exception thrown when an object reference is unexpectedly not null. - - - - - Creates a new instance of the class. - - - - - - - - - Command that automatically creates the instance of the test class - and disposes it (if it implements ). - - - - - Creates a new instance of the object. - - The command that is bring wrapped - The method under test - - - - Executes the test method. Creates a new instance of the class - under tests and passes it to the inner command. Also catches - any exceptions and converts them into s. - - The instance of the test class - Returns information about the test run - - - - Command used to wrap a which has associated - fixture data. - - - - - Creates a new instance of the class. - - The inner command - The fixtures to be set on the test class - - - - Sets the fixtures on the test class by calling SetFixture, then - calls the inner command. - - The instance of the test class - Returns information about the test run - - - - A timer class used to figure out how long tests take to run. On most .NET implementations - this will use the class because it's a high - resolution timer; however, on Silverlight/CoreCLR, it will use - (which will provide lower resolution results). - - - - - Creates a new instance of the class. - - - - - Starts timing. - - - - - Stops timing. - - - - - Gets how long the timer ran, in milliseconds. In order for this to be valid, - both and must have been called. - - - - - Attribute used to decorate a test method with arbitrary name/value pairs ("traits"). - - - - - Creates a new instance of the class. - - The trait name - The trait value - - - - Gets the trait name. - - - - - - - - Gets the trait value. - - - - - Runner that executes an synchronously. - - - - - Execute the . - - The test class command to execute - The methods to execute; if null or empty, all methods will be executed - The start run callback - The end run result callback - A with the results of the test run - - - - Factory for objects, based on the type under test. - - - - - Creates the test class command, which implements , for a given type. - - The type under test - The test class command, if the class is a test class; null, otherwise - - - - Creates the test class command, which implements , for a given type. - - The type under test - The test class command, if the class is a test class; null, otherwise - - - - Represents an xUnit.net test class - - - - - Interface which describes the ability to executes all the tests in a test class. - - - - - Allows the test class command to choose the next test to be run from the list of - tests that have not yet been run, thereby allowing it to choose the run order. - - The tests remaining to be run - The index of the test that should be run - - - - Execute actions to be run after all the test methods of this test class are run. - - Returns the thrown during execution, if any; null, otherwise - - - - Execute actions to be run before any of the test methods of this test class are run. - - Returns the thrown during execution, if any; null, otherwise - - - - Enumerates the test commands for a given test method in this test class. - - The method under test - The test commands for the given test method - - - - Enumerates the methods which are test methods in this test class. - - The test methods - - - - Determines if a given refers to a test method. - - The test method to validate - True if the method is a test method; false, otherwise - - - - Gets the object instance that is under test. May return null if you wish - the test framework to create a new object instance for each test method. - - - - - Gets or sets the type that is being tested - - - - - Creates a new instance of the class. - - - - - Creates a new instance of the class. - - The type under test - - - - Creates a new instance of the class. - - The type under test - - - - Chooses the next test to run, randomly, using the . - - The tests remaining to be run - The index of the test that should be run - - - - Execute actions to be run after all the test methods of this test class are run. - - Returns the thrown during execution, if any; null, otherwise - - - - Execute actions to be run before any of the test methods of this test class are run. - - Returns the thrown during execution, if any; null, otherwise - - - - Enumerates the test commands for a given test method in this test class. - - The method under test - The test commands for the given test method - - - - Enumerates the methods which are test methods in this test class. - - The test methods - - - - Determines if a given refers to a test method. - - The test method to validate - True if the method is a test method; false, otherwise - - - - Gets the object instance that is under test. May return null if you wish - the test framework to create a new object instance for each test method. - - - - - Gets or sets the randomizer used to determine the order in which tests are run. - - - - - Sets the type that is being tested - - - - - Implementation of that represents a skipped test. - - - - - Creates a new instance of the class. - - The method that is being skipped - The display name for the test. If null, the fully qualified - type name is used. - The reason the test was skipped. - - - - - - - - - - Gets the skip reason. - - - - - - - - Factory for creating objects. - - - - - Make instances of objects for the given class and method. - - The class command - The method under test - The set of objects - - - - A command wrapper which times the running of a command. - - - - - Creates a new instance of the class. - - The command that will be timed. - - - - Executes the inner test method, gathering the amount of time it takes to run. - - Returns information about the test run - - - - Wraps a command which should fail if it runs longer than the given timeout value. - - - - - Creates a new instance of the class. - - The command to be run - The timout, in milliseconds - The method under test - - - - Executes the test method, failing if it takes too long. - - Returns information about the test run - - - - - - - Attributes used to decorate a test fixture that is run with an alternate test runner. - The test runner must implement the interface. - - - - - Creates a new instance of the class. - - The class which implements ITestClassCommand and acts as the runner - for the test fixture. - - - - Gets the test class command. - - - - - Exception thrown when two object references are unexpectedly not the same instance. - - - - - Creates a new instance of the class. - - The expected object reference - The actual object reference - - - - - - - Contains the test results from an assembly. - - - - - Contains multiple test results, representing them as a composite test result. - - - - - Adds a test result to the composite test result list. - - - - - - Gets the test results. - - - - - Creates a new instance of the class. - - The filename of the assembly - - - - Creates a new instance of the class. - - The filename of the assembly - The configuration filename - - - - Converts the test result into XML that is consumed by the test runners. - - The parent node. - The newly created XML node. - - - - Gets the fully qualified filename of the configuration file. - - - - - Gets the directory where the assembly resides. - - - - - Gets the number of failed results. - - - - - Gets the fully qualified filename of the assembly. - - - - - Gets the number of passed results. - - - - - Gets the number of skipped results. - - - - - Contains the test results from a test class. - - - - - Creates a new instance of the class. - - The type under test - - - - Creates a new instance of the class. - - The simple name of the type under test - The fully qualified name of the type under test - The namespace of the type under test - - - - Sets the exception thrown by the test fixture. - - The thrown exception - - - - Converts the test result into XML that is consumed by the test runners. - - The parent node. - The newly created XML node. - - - - Gets the fully qualified test fixture exception type, when an exception has occurred. - - - - - Gets the number of tests which failed. - - - - - Gets the fully qualified name of the type under test. - - - - - Gets the test fixture exception message, when an exception has occurred. - - - - - Gets the simple name of the type under test. - - - - - Gets the namespace of the type under test. - - - - - Gets the number of tests which passed. - - - - - Gets the number of tests which were skipped. - - - - - Gets the test fixture exception stack trace, when an exception has occurred. - - - - - Represents a failed test result. - - - - - Represents the results from running a test method - - - - - Initializes a new instance of the class. The traits for - the test method are discovered using reflection. - - The method under test. - The display name for the test. If null, the fully qualified - type name is used. - - - - Initializes a new instance of the class. - - The name of the method under test. - The type of the method under test. - The display name for the test. If null, the fully qualified - type name is used. - The traits. - - - - Converts the test result into XML that is consumed by the test runners. - - The parent node. - The newly created XML node. - - - - Gets or sets the display name of the method under test. This is the value that's shown - during failures and in the resulting output XML. - - - - - Gets the name of the method under test. - - - - - Gets or sets the standard output/standard error from the test that was captured - while the test was running. - - - - - Gets the traits attached to the test method. - - - - - Gets the name of the type under test. - - - - - Creates a new instance of the class. - - The method under test - The exception throw by the test - The display name for the test. If null, the fully qualified - type name is used. - - - - Creates a new instance of the class. - - The name of the method under test - The name of the type under test - The display name of the test - The custom properties attached to the test method - The full type name of the exception throw - The exception message - The exception stack trace - - - - Converts the test result into XML that is consumed by the test runners. - - The parent node. - The newly created XML node. - - - - Gets the exception type thrown by the test method. - - - - - Gets the exception message thrown by the test method. - - - - - Gets the stack trace of the exception thrown by the test method. - - - - - Represents a passing test result. - - - - - Create a new instance of the class. - - The method under test - The display name for the test. If null, the fully qualified - type name is used. - - - - Create a new instance of the class. - - The name of the method under test - The name of the type under test - The display name for the test. If null, the fully qualified - type name is used. - The custom properties attached to the test method - - - - Converts the test result into XML that is consumed by the test runners. - - The parent node. - The newly created XML node. - - - - Represents a skipped test result. - - - - - Creates a new instance of the class. Uses reflection to discover - the skip reason. - - The method under test - The display name for the test. If null, the fully qualified - type name is used. - The reason the test was skipped. - - - - Creates a new instance of the class. - - The name of the method under test - The name of the type under test - The display name for the test. If null, the fully qualified - type name is used. - The traits attached to the method under test - The skip reason - - - - Converts the test result into XML that is consumed by the test runners. - - The parent node. - The newly created XML node. - - - - Gets the skip reason. - - - - - Represents information about an attribute. - - - - - Gets the instance of the attribute, if available. - - The type of the attribute - The instance of the attribute, if available. - - - - Gets an initialized property value of the attribute. - - The type of the property - The name of the property - The property value - - - - Represents information about a method. - - - - - Creates an instance of the type where this test method was found. If using - reflection, this should be the ReflectedType. - - A new instance of the type. - - - - Gets all the custom attributes for the method that are of the given type. - - The type of the attribute - The matching attributes that decorate the method - - - - Determines if the method has at least one instance of the given attribute type. - - The type of the attribute - True if the method has at least one instance of the given attribute type; false, otherwise - - - - Invokes the test on the given class, with the given parameters. - - The instance of the test class (may be null if - the test method is static). - The parameters to be passed to the test method. - - - - Gets a value which represents the class that this method was - reflected from (i.e., equivalent to MethodInfo.ReflectedType) - - - - - Gets a value indicating whether the method is abstract. - - - - - Gets a value indicating whether the method is static. - - - - - Gets the underlying for the method, if available. - - - - - Gets the name of the method. - - - - - Gets the fully qualified type name of the return type. - - - - - Gets the fully qualified type name of the type that this method belongs to. If - using reflection, this should be the ReflectedType. - - - - - Represents information about a type. - - - - - Gets all the custom attributes for the type that are of the given attribute type. - - The type of the attribute - The matching attributes that decorate the type - - - - Gets a test method by name. - - The name of the method - The method, if it exists; null, otherwise. - - - - Gets all the methods - - - - - - Determines if the type has at least one instance of the given attribute type. - - The type of the attribute - True if the type has at least one instance of the given attribute type; false, otherwise - - - - Determines if the type implements the given interface. - - The type of the interface - True if the type implements the given interface; false, otherwise - - - - Gets a value indicating whether the type is abstract. - - - - - Gets a value indicating whether the type is sealed. - - - - - Gets the underlying object, if available. - - - - - Utility class which inspects methods for test information - - - - - Gets the display name. - - The method to be inspected - The display name - - - - Gets the skip reason from a test method. - - The method to be inspected - The skip reason - - - - Gets the test commands for a test method. - - The method to be inspected - The objects for the test method - - - - Gets the timeout value for a test method. - - The method to be inspected - The timeout, in milliseconds - - - - Gets the traits on a test method. - - The method to be inspected - A dictionary of the traits - - - - Determines whether a test method has a timeout. - - The method to be inspected - True if the method has a timeout; false, otherwise - - - - Determines whether a test method has traits. - - The method to be inspected - True if the method has traits; false, otherwise - - - - Determines whether a test method should be skipped. - - The method to be inspected - True if the method should be skipped; false, otherwise - - - - Determines whether a method is a test method. A test method must be decorated - with the (or derived class) and must not be abstract. - - The method to be inspected - True if the method is a test method; false, otherwise - - - - Wrapper to implement and using reflection. - - - - - Converts an into an using reflection. - - - - - - - Converts a into an using reflection. - - The method to wrap - The wrapper - - - - Converts a into an using reflection. - - The type to wrap - The wrapper - - - - Utility class which inspects types for test information - - - - - Determines if a type contains any test methods - - The type to be inspected - True if the class contains any test methods; false, otherwise - - - - Retrieves the type to run the test class with from the , if present. - - The type to be inspected - The type of the test class runner, if present; null, otherwise - - - - Retrieves a list of the test methods from the test class. - - The type to be inspected - The test methods - - - - Determines if the test class has a applied to it. - - The type to be inspected - True if the test class has a run with attribute; false, otherwise - - - - Determines if the type implements . - - The type to be inspected - True if the type implements ; false, otherwise - - - - Determines whether the specified type is abstract. - - The type. - - true if the specified type is abstract; otherwise, false. - - - - - Determines whether the specified type is static. - - The type. - - true if the specified type is static; otherwise, false. - - - - - Determines if a class is a test class. - - The type to be inspected - True if the type is a test class; false, otherwise - - - - Attribute that is applied to a method to indicate that it is a fact that should be run - by the test runner. It can also be extended to support a customized definition of a - test method. - - - - - Creates instances of which represent individual intended - invocations of the test method. - - The method under test - An enumerator through the desired test method invocations - - - - Enumerates the test commands represented by this test method. Derived classes should - override this method to return instances of , one per execution - of a test method. - - The test method - The test commands which will execute the test runs for the given method - - - - Gets the name of the test to be used when the test is skipped. Defaults to - null, which will cause the fully qualified test name to be used. - - - - - Obsolete. Please use the property instead. - - - - - Marks the test so that it will not be run, and gets or sets the skip reason - - - - - Marks the test as failing if it does not finish running within the given time - period, in milliseconds; set to 0 or less to indicate the method has no timeout - - - - - Exception thrown when code unexpectedly fails to throw an exception. - - - - - Creates a new instance of the class. Call this constructor - when no exception was thrown. - - The type of the exception that was expected - - - - Creates a new instance of the class. Call this constructor - when an exception of the wrong type was thrown. - - The type of the exception that was expected - The actual exception that was thrown - - - - - - - THIS CONSTRUCTOR IS FOR UNIT TESTING PURPOSES ONLY. - - - - - - - - Gets a string representation of the frames on the call stack at the time the current exception was thrown. - - A string that describes the contents of the call stack, with the most recent method call appearing first. - - - - Exception thrown when a test method exceeds the given timeout value - - - - - Creates a new instance of the class. - - The timeout value, in milliseconds - - - - - - - Exception thrown when a value is unexpectedly false. - - - - - Creates a new instance of the class. - - The user message to be displayed, or null for the default message - - - - - - diff --git a/LibGit2Sharp.Tests/ArchiveFixture.cs b/LibGit2Sharp.Tests/ArchiveFixture.cs index e070db85d..7253e2fe8 100644 --- a/LibGit2Sharp.Tests/ArchiveFixture.cs +++ b/LibGit2Sharp.Tests/ArchiveFixture.cs @@ -11,7 +11,8 @@ public class ArchiveFixture : BaseFixture [Fact] public void CanArchiveATree() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Lookup("581f9824ecaf824221bd36edf5430f2739a7c4f5"); @@ -36,7 +37,8 @@ public void CanArchiveATree() [Fact] public void CanArchiveACommit() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commit = repo.Lookup("4c062a6361ae6959e06292c1fa5e2822d9c96345"); @@ -61,7 +63,8 @@ public void CanArchiveACommit() [Fact] public void ArchivingANullTreeOrCommitThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.ObjectDatabase.Archive((Commit)null, null)); Assert.Throws(() => repo.ObjectDatabase.Archive((Tree)null, null)); diff --git a/LibGit2Sharp.Tests/ArchiveTarFixture.cs b/LibGit2Sharp.Tests/ArchiveTarFixture.cs index a59b23604..c1ae15783 100644 --- a/LibGit2Sharp.Tests/ArchiveTarFixture.cs +++ b/LibGit2Sharp.Tests/ArchiveTarFixture.cs @@ -11,7 +11,7 @@ public class ArchiveTarFixture : BaseFixture [Fact] public void CanArchiveACommitWithDirectoryAsTar() { - var path = CloneBareTestRepo(); + var path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { // This tests generates an archive of the bare test repo, and compares it with @@ -26,7 +26,7 @@ public void CanArchiveACommitWithDirectoryAsTar() var commit = repo.Lookup("4c062a6361ae6959e06292c1fa5e2822d9c96345"); var scd = BuildSelfCleaningDirectory(); - var archivePath = Path.Combine(scd.RootedDirectoryPath, Guid.NewGuid() + ".tar"); + var archivePath = Path.Combine(scd.RootedDirectoryPath, Path.GetRandomFileName() + ".tar"); Directory.CreateDirectory(scd.RootedDirectoryPath); repo.ObjectDatabase.Archive(commit, archivePath); diff --git a/LibGit2Sharp.Tests/AttributesFixture.cs b/LibGit2Sharp.Tests/AttributesFixture.cs index b6700becb..c9c4eb712 100644 --- a/LibGit2Sharp.Tests/AttributesFixture.cs +++ b/LibGit2Sharp.Tests/AttributesFixture.cs @@ -9,7 +9,7 @@ public class AttributesFixture : BaseFixture [Fact] public void StagingHonorsTheAttributesFiles() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { CreateAttributesFile(repo); diff --git a/LibGit2Sharp.Tests/BlameFixture.cs b/LibGit2Sharp.Tests/BlameFixture.cs index b0fcf77fe..9138646c3 100644 --- a/LibGit2Sharp.Tests/BlameFixture.cs +++ b/LibGit2Sharp.Tests/BlameFixture.cs @@ -22,7 +22,8 @@ private static void AssertCorrectHeadBlame(BlameHunkCollection blame) [Fact] public void CanBlameSimply() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { AssertCorrectHeadBlame(repo.Blame("README")); } @@ -31,10 +32,11 @@ public void CanBlameSimply() [Fact] public void CanBlameFromADifferentCommit() { - using (var repo = new Repository(MergedTestRepoWorkingDirPath)) + string path = SandboxMergedTestRepo(); + using (var repo = new Repository(path)) { // File doesn't exist at HEAD - Assert.Throws(() => repo.Blame("ancestor-only.txt")); + Assert.Throws(() => repo.Blame("ancestor-only.txt")); var blame = repo.Blame("ancestor-only.txt", new BlameOptions { StartingAt = "9107b30" }); Assert.Equal(1, blame.Count()); @@ -44,7 +46,8 @@ public void CanBlameFromADifferentCommit() [Fact] public void ValidatesLimits() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var blame = repo.Blame("README"); @@ -56,7 +59,8 @@ public void ValidatesLimits() [Fact] public void CanBlameFromVariousTypes() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions {StartingAt = "HEAD" })); AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions {StartingAt = repo.Head })); @@ -68,7 +72,8 @@ public void CanBlameFromVariousTypes() [Fact] public void CanStopBlame() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { // $ git blame .\new.txt // 9fd738e8 (Scott Chacon 2010-05-24 10:19:19 -0700 1) my new file diff --git a/LibGit2Sharp.Tests/BlobFixture.cs b/LibGit2Sharp.Tests/BlobFixture.cs index 8e2722425..223a4d673 100644 --- a/LibGit2Sharp.Tests/BlobFixture.cs +++ b/LibGit2Sharp.Tests/BlobFixture.cs @@ -12,7 +12,8 @@ public class BlobFixture : BaseFixture [Fact] public void CanGetBlobAsText() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("a8233120f6ad708f843d861ce2b7228ec4e3dec6"); @@ -30,7 +31,7 @@ public void CanGetBlobAsFilteredText(string autocrlf, string expectedText) { SkipIfNotSupported(autocrlf); - var path = CloneBareTestRepo(); + var path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("core.autocrlf", autocrlf); @@ -52,7 +53,7 @@ public void CanGetBlobAsFilteredText(string autocrlf, string expectedText) [InlineData("utf-32", 20, "FF FE 00 00 31 00 00 00 32 00 00 00 33 00 00 00 34 00 00 00")] public void CanGetBlobAsTextWithVariousEncodings(string encodingName, int expectedContentBytes, string expectedUtf7Chars) { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var bomFile = "bom.txt"; @@ -86,7 +87,8 @@ public void CanGetBlobAsTextWithVariousEncodings(string encodingName, int expect [Fact] public void CanGetBlobSize() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("a8233120f6ad708f843d861ce2b7228ec4e3dec6"); Assert.Equal(10, blob.Size); @@ -96,7 +98,8 @@ public void CanGetBlobSize() [Fact] public void CanLookUpBlob() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("a8233120f6ad708f843d861ce2b7228ec4e3dec6"); Assert.NotNull(blob); @@ -106,7 +109,8 @@ public void CanLookUpBlob() [Fact] public void CanReadBlobStream() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("a8233120f6ad708f843d861ce2b7228ec4e3dec6"); @@ -129,7 +133,7 @@ public void CanReadBlobFilteredStream(string autocrlf, string expectedContent) { SkipIfNotSupported(autocrlf); - var path = CloneBareTestRepo(); + var path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("core.autocrlf", autocrlf); @@ -153,7 +157,7 @@ public void CanReadBlobFilteredStreamOfUnmodifiedBinary() { var binaryContent = new byte[] { 0, 1, 2, 3, 4, 5 }; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { using (var stream = new MemoryStream(binaryContent)) @@ -208,7 +212,8 @@ public void CanStageAFileGeneratedFromABlobContentStream() [Fact] public void CanTellIfTheBlobContentLooksLikeBinary() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("a8233120f6ad708f843d861ce2b7228ec4e3dec6"); Assert.Equal(false, blob.IsBinary); diff --git a/LibGit2Sharp.Tests/BranchFixture.cs b/LibGit2Sharp.Tests/BranchFixture.cs index 908d0f414..ded3fbc76 100644 --- a/LibGit2Sharp.Tests/BranchFixture.cs +++ b/LibGit2Sharp.Tests/BranchFixture.cs @@ -17,7 +17,7 @@ public class BranchFixture : BaseFixture [InlineData("Ångström")] public void CanCreateBranch(string name) { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -50,7 +50,7 @@ public void CanCreateBranch(string name) [Fact] public void CanCreateAnUnbornBranch() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // No branch named orphan @@ -85,7 +85,7 @@ public void CanCreateAnUnbornBranch() [Fact] public void CanCreateBranchUsingAbbreviatedSha() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -108,7 +108,7 @@ public void CanCreateBranchUsingAbbreviatedSha() [InlineData("master")] public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -136,7 +136,7 @@ public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec) [InlineData("master")] public void CanCreateBranchFromExplicitHead(string headCommitOrBranchSpec) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -157,7 +157,7 @@ public void CanCreateBranchFromExplicitHead(string headCommitOrBranchSpec) [Fact] public void CanCreateBranchFromCommit() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -177,7 +177,7 @@ public void CanCreateBranchFromCommit() [Fact] public void CanCreateBranchFromRevparseSpec() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -200,7 +200,7 @@ public void CanCreateBranchFromRevparseSpec() [InlineData("refs/tags/test")] public void CreatingABranchFromATagPeelsToTheCommit(string committish) { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -220,7 +220,7 @@ public void CreatingABranchFromATagPeelsToTheCommit(string committish) [Fact] public void CreatingABranchTriggersTheCreationOfADirectReference() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Branch newBranch = repo.CreateBranch("clone-of-master"); @@ -238,38 +238,42 @@ public void CreatingABranchTriggersTheCreationOfADirectReference() [Fact] public void CreatingABranchFromANonCommitObjectThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { const string name = "sorry-dude-i-do-not-do-blobs-nor-trees"; - Assert.Throws(() => repo.CreateBranch(name, "refs/tags/point_to_blob")); - Assert.Throws(() => repo.CreateBranch(name, "53fc32d")); - Assert.Throws(() => repo.CreateBranch(name, "0266163")); + Assert.Throws(() => repo.CreateBranch(name, "refs/tags/point_to_blob")); + Assert.Throws(() => repo.CreateBranch(name, "53fc32d")); + Assert.Throws(() => repo.CreateBranch(name, "0266163")); } } [Fact] public void CreatingBranchWithUnknownNamedTargetThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { - Assert.Throws(() => repo.Branches.Add("my_new_branch", "my_old_branch")); + Assert.Throws(() => repo.Branches.Add("my_new_branch", "my_old_branch")); } } [Fact] public void CreatingBranchWithUnknownShaTargetThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { - Assert.Throws(() => repo.Branches.Add("my_new_branch", Constants.UnknownSha)); - Assert.Throws(() => repo.Branches.Add("my_new_branch", Constants.UnknownSha.Substring(0, 7))); + Assert.Throws(() => repo.Branches.Add("my_new_branch", Constants.UnknownSha)); + Assert.Throws(() => repo.Branches.Add("my_new_branch", Constants.UnknownSha.Substring(0, 7))); } } [Fact] public void CreatingBranchWithBadParamsThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Branches.Add(null, repo.Head.CanonicalName)); Assert.Throws(() => repo.Branches.Add(string.Empty, repo.Head.CanonicalName)); @@ -282,7 +286,8 @@ public void CreatingBranchWithBadParamsThrows() [Fact] public void CanListAllBranches() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(expectedBranches, SortedBranches(repo.Branches, b => b.Name)); @@ -293,7 +298,7 @@ public void CanListAllBranches() [Fact] public void CanListBranchesWithRemoteAndLocalBranchWithSameShortName() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Create a local branch with the same short name as a remote branch. @@ -312,7 +317,8 @@ public void CanListBranchesWithRemoteAndLocalBranchWithSameShortName() [Fact] public void CanListAllBranchesWhenGivenWorkingDir() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { var expectedWdBranches = new[] { @@ -328,7 +334,8 @@ public void CanListAllBranchesWhenGivenWorkingDir() [Fact] public void CanListAllBranchesIncludingRemoteRefs() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { var expectedBranchesIncludingRemoteRefs = new[] { @@ -352,7 +359,8 @@ public void CanListAllBranchesIncludingRemoteRefs() [Fact] public void CanResolveRemote() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; Assert.Equal(repo.Network.Remotes["origin"], master.Remote); @@ -362,7 +370,8 @@ public void CanResolveRemote() [Fact] public void RemoteAndUpstreamBranchCanonicalNameForNonTrackingBranchIsNull() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Branch test = repo.Branches["i-do-numbers"]; Assert.Null(test.Remote); @@ -374,7 +383,8 @@ public void RemoteAndUpstreamBranchCanonicalNameForNonTrackingBranchIsNull() public void QueryRemoteForLocalTrackingBranch() { // There is not a Remote to resolve for a local tracking branch. - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Branch trackLocal = repo.Branches["track-local"]; Assert.Null(trackLocal.Remote); @@ -384,7 +394,8 @@ public void QueryRemoteForLocalTrackingBranch() [Fact] public void QueryUpstreamBranchCanonicalNameForLocalTrackingBranch() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Branch trackLocal = repo.Branches["track-local"]; Assert.Equal("refs/heads/master", trackLocal.UpstreamBranchCanonicalName); @@ -394,7 +405,8 @@ public void QueryUpstreamBranchCanonicalNameForLocalTrackingBranch() [Fact] public void QueryRemoteForRemoteBranch() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { var master = repo.Branches["origin/master"]; Assert.Equal(repo.Network.Remotes["origin"], master.Remote); @@ -404,7 +416,7 @@ public void QueryRemoteForRemoteBranch() [Fact] public void QueryUnresolvableRemoteForRemoteBranch() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); var fetchRefSpecs = new string[] { "+refs/heads/notfound/*:refs/remotes/origin/notfound/*" }; @@ -429,7 +441,7 @@ public void QueryUnresolvableRemoteForRemoteBranch() [Fact] public void QueryAmbigousRemoteForRemoteBranch() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); var fetchRefSpec = "+refs/heads/*:refs/remotes/origin/*"; var url = "http://github.com/libgit2/TestGitRepository"; @@ -452,7 +464,8 @@ public void QueryAmbigousRemoteForRemoteBranch() [Fact] public void CanLookupABranchByItsCanonicalName() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch branch = repo.Branches["refs/heads/br2"]; Assert.NotNull(branch); @@ -470,7 +483,8 @@ public void CanLookupABranchByItsCanonicalName() [Fact] public void CanLookupLocalBranch() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; Assert.NotNull(master); @@ -485,7 +499,7 @@ public void CanLookupLocalBranch() [Fact] public void CanLookupABranchWhichNameIsMadeOfNon7BitsAsciiCharacters() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string name = "Ångström"; @@ -501,7 +515,8 @@ public void CanLookupABranchWhichNameIsMadeOfNon7BitsAsciiCharacters() [Fact] public void LookingOutABranchByNameWithBadParamsThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch branch; Assert.Throws(() => branch = repo.Branches[null]); @@ -539,7 +554,7 @@ public void CanGetInformationFromUnbornBranch() [Fact] public void CanGetTrackingInformationFromBranchSharingNoHistoryWithItsTrackedBranch() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; @@ -565,7 +580,7 @@ public void CanGetTrackingInformationFromBranchSharingNoHistoryWithItsTrackedBra [Fact] public void TrackingInformationIsEmptyForBranchTrackingPrunedRemoteBranch() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { const string remoteRef = "refs/remotes/origin/master"; @@ -587,7 +602,8 @@ public void TrackingInformationIsEmptyForBranchTrackingPrunedRemoteBranch() [Fact] public void TrackingInformationIsEmptyForNonTrackingBranch() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch branch = repo.Branches["test"]; Assert.False(branch.IsTracking); @@ -603,7 +619,8 @@ public void TrackingInformationIsEmptyForNonTrackingBranch() [Fact] public void CanGetTrackingInformationForTrackingBranch() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; Assert.True(master.IsTracking); @@ -619,7 +636,8 @@ public void CanGetTrackingInformationForTrackingBranch() [Fact] public void CanGetTrackingInformationForLocalTrackingBranch() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { var branch = repo.Branches["track-local"]; Assert.True(branch.IsTracking); @@ -635,7 +653,8 @@ public void CanGetTrackingInformationForLocalTrackingBranch() [Fact] public void RenamingARemoteTrackingBranchThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Branch master = repo.Branches["refs/remotes/origin/master"]; Assert.True(master.IsRemote); @@ -647,7 +666,8 @@ public void RenamingARemoteTrackingBranchThrows() [Fact] public void CanWalkCommitsFromAnotherBranch() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch master = repo.Branches["test"]; Assert.Equal(2, master.Commits.Count()); @@ -660,13 +680,15 @@ public void CanSetTrackedBranch() const string testBranchName = "branchToSetUpstreamInfoFor"; const string trackedBranchName = "refs/remotes/origin/master"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { - Branch branch = repo.CreateBranch(testBranchName); + Branch trackedBranch = repo.Branches[trackedBranchName]; + Assert.True(trackedBranch.IsRemote); + + Branch branch = repo.CreateBranch(testBranchName, trackedBranch.Tip); Assert.False(branch.IsTracking); - Branch trackedBranch = repo.Branches[trackedBranchName]; repo.Branches.Update(branch, b => b.TrackedBranch = trackedBranch.CanonicalName); @@ -692,7 +714,7 @@ public void SetTrackedBranchForUnreasolvableRemoteThrows() const string trackedBranchName = "refs/remotes/origin/master"; var fetchRefSpecs = new string[] { "+refs/heads/notfound/*:refs/remotes/origin/notfound/*" }; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Modify the fetch spec so that the remote for the remote-tracking branch @@ -707,7 +729,7 @@ public void SetTrackedBranchForUnreasolvableRemoteThrows() Branch trackedBranch = repo.Branches[trackedBranchName]; - Assert.Throws(() => repo.Branches.Update(branch, + Assert.Throws(() => repo.Branches.Update(branch, b => b.TrackedBranch = trackedBranch.CanonicalName)); } } @@ -720,13 +742,15 @@ public void CanSetUpstreamBranch() const string trackedBranchName = "refs/remotes/origin/master"; const string remoteName = "origin"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { - Branch branch = repo.CreateBranch(testBranchName); + Branch trackedBranch = repo.Branches[trackedBranchName]; + Assert.True(trackedBranch.IsRemote); + + Branch branch = repo.CreateBranch(testBranchName, trackedBranch.Tip); Assert.False(branch.IsTracking); - Branch trackedBranch = repo.Branches[trackedBranchName]; Branch updatedBranch = repo.Branches.Update(branch, b => b.Remote = remoteName, b => b.UpstreamBranch = upstreamBranchName); @@ -750,13 +774,14 @@ public void CanSetLocalTrackedBranch() const string testBranchName = "branchToSetUpstreamInfoFor"; const string localTrackedBranchName = "refs/heads/master"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { - Branch branch = repo.CreateBranch(testBranchName); - Assert.False(branch.IsTracking); - Branch trackedBranch = repo.Branches[localTrackedBranchName]; + Assert.False(trackedBranch.IsRemote); + + Branch branch = repo.CreateBranch(testBranchName, trackedBranch.Tip); + Assert.False(branch.IsTracking); repo.Branches.Update(branch, b => b.TrackedBranch = trackedBranch.CanonicalName); @@ -788,14 +813,16 @@ public void CanUnsetTrackedBranch() const string testBranchName = "branchToSetUpstreamInfoFor"; const string trackedBranchName = "refs/remotes/origin/master"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { - Branch branch = repo.CreateBranch(testBranchName); + Branch trackedBranch = repo.Branches[trackedBranchName]; + + Branch branch = repo.CreateBranch(testBranchName, trackedBranch.Tip); Assert.False(branch.IsTracking); branch = repo.Branches.Update(branch, - b => b.TrackedBranch = trackedBranchName); + b => b.TrackedBranch = trackedBranch.CanonicalName); // Got the updated branch from the Update() method Assert.True(branch.IsTracking); @@ -813,7 +840,8 @@ public void CanUnsetTrackedBranch() [Fact] public void CanWalkCommitsFromBranch() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; Assert.Equal(7, master.Commits.Count()); @@ -822,7 +850,7 @@ public void CanWalkCommitsFromBranch() private void AssertRemoval(string branchName, bool isRemote, bool shouldPreviouslyAssertExistence) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { if (shouldPreviouslyAssertExistence) @@ -849,7 +877,7 @@ public void CanRemoveAnExistingNamedBranch(string branchName, bool isRemote) [InlineData("origin/br2")] public void CanRemoveAnExistingBranch(string branchName) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Branch curBranch = repo.Branches[branchName]; @@ -871,7 +899,8 @@ public void CanRemoveANonExistingBranch(string branchName, bool isRemote) [Fact] public void RemovingABranchWhichIsTheCurrentHeadThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Branches.Remove(repo.Head.Name)); } @@ -880,7 +909,8 @@ public void RemovingABranchWhichIsTheCurrentHeadThrows() [Fact] public void RemovingABranchWithBadParamsThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Branches.Remove(string.Empty)); Assert.Throws(() => repo.Branches.Remove(null)); @@ -890,7 +920,8 @@ public void RemovingABranchWithBadParamsThrows() [Fact] public void OnlyOneBranchIsTheHead() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch head = null; @@ -919,7 +950,7 @@ public void OnlyOneBranchIsTheHead() [Fact] public void TwoBranchesPointingAtTheSameCommitAreNotBothCurrent() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Branch master = repo.Branches["refs/heads/master"]; @@ -932,7 +963,7 @@ public void TwoBranchesPointingAtTheSameCommitAreNotBothCurrent() [Fact] public void CanRenameABranch() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -957,7 +988,8 @@ public void CanRenameABranch() [Fact] public void BlindlyRenamingABranchOverAnExistingOneThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Branches.Rename("br2", "test")); } @@ -966,7 +998,7 @@ public void BlindlyRenamingABranchOverAnExistingOneThrows() [Fact] public void CanRenameABranchWhileOverwritingAnExistingOne() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -998,7 +1030,7 @@ public void CanRenameABranchWhileOverwritingAnExistingOne() [Fact] public void DetachedHeadIsNotATrackingBranch() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); @@ -1068,7 +1100,8 @@ public void TrackedBranchExistsFromDefaultConfigInEmptyClone() [Fact] public void RemoteBranchesDoNotTrackAnything() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { var branches = repo.Branches.Where(b => b.IsRemote); @@ -1095,7 +1128,7 @@ private static T[] SortedBranches(IEnumerable branches, Func(() => repo.Checkout(repo.Branches["refs/heads/test"])); Assert.Throws(() => repo.Checkout("refs/heads/test")); @@ -379,16 +380,18 @@ public void CheckingOutAgainstAnUnbornBranchThrows() [Fact] public void CheckingOutANonExistingBranchThrows() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { - Assert.Throws(() => repo.Checkout("i-do-not-exist")); + Assert.Throws(() => repo.Checkout("i-do-not-exist")); } } [Fact] public void CheckingOutABranchWithBadParamsThrows() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Checkout(string.Empty)); Assert.Throws(() => repo.Checkout(default(Branch))); @@ -407,7 +410,8 @@ public void CheckingOutThroughBranchCallsCheckoutProgress() bool wasCalled = false; Branch branch = repo.Branches[otherBranchName]; - branch.Checkout(new CheckoutOptions() { OnCheckoutProgress = (path, completed, total) => wasCalled = true}); + repo.Checkout(branch, + new CheckoutOptions { OnCheckoutProgress = (path, completed, total) => wasCalled = true}); Assert.True(wasCalled); } @@ -681,7 +685,7 @@ public void CheckoutBranchSnapshot() Assert.False(repo.Info.IsHeadDetached); - initial.Checkout(); + repo.Checkout(initial); // Head should point at initial commit. Assert.Equal(repo.Head.Tip, initialCommit); @@ -699,7 +703,7 @@ public void CheckoutBranchSnapshot() [InlineData("origin/master")] public void CheckingOutRemoteBranchResultsInDetachedHead(string remoteBranchSpec) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; @@ -719,7 +723,7 @@ public void CheckingOutRemoteBranchResultsInDetachedHead(string remoteBranchSpec [Fact] public void CheckingOutABranchDoesNotAlterBinaryFiles() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // $ git hash-object square-logo.png @@ -748,7 +752,7 @@ public void CheckingOutABranchDoesNotAlterBinaryFiles() [InlineData("e90810^{}")] public void CheckoutFromDetachedHead(string commitPointer) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Set the working directory to the current head @@ -774,7 +778,7 @@ public void CheckoutFromDetachedHead(string commitPointer) [Fact] public void CheckoutBranchFromDetachedHead() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Set the working directory to the current head @@ -799,7 +803,7 @@ public void CheckoutBranchFromDetachedHead() [InlineData("heads/master", "refs/heads/master")] public void CheckoutBranchByShortNameAttachesTheHead(string shortBranchName, string referenceName) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Set the working directory to the current head @@ -820,7 +824,7 @@ public void CheckoutBranchByShortNameAttachesTheHead(string shortBranchName, str [Fact] public void CheckoutPreviousCheckedOutBranch() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Set the working directory to the current head @@ -842,7 +846,7 @@ public void CheckoutPreviousCheckedOutBranch() [Fact] public void CheckoutCurrentReference() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; @@ -889,16 +893,17 @@ public void CheckoutCurrentReference() [Fact] public void CheckoutLowerCasedHeadThrows() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { - Assert.Throws(() => repo.Checkout("head")); + Assert.Throws(() => repo.Checkout("head")); } } [Fact] public void CanCheckoutAttachedHead() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.False(repo.Info.IsHeadDetached); @@ -914,7 +919,7 @@ public void CanCheckoutAttachedHead() [Fact] public void CanCheckoutDetachedHead() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Checkout(repo.Head.Tip.Sha); @@ -936,7 +941,7 @@ public void CanCheckoutDetachedHead() [InlineData("i-do-numbers", "diff-test-cases", "numbers.txt", FileStatus.Staged)] public void CanCheckoutPath(string originalBranch, string checkoutFrom, string path, FileStatus expectedStatus) { - string repoPath = CloneStandardTestRepo(); + string repoPath = SandboxStandardTestRepo(); using (var repo = new Repository(repoPath)) { // Set the working directory to the current head @@ -955,7 +960,7 @@ public void CanCheckoutPath(string originalBranch, string checkoutFrom, string p [Fact] public void CanCheckoutPaths() { - string repoPath = CloneStandardTestRepo(); + string repoPath = SandboxStandardTestRepo(); var checkoutPaths = new[] { "numbers.txt", "super-file.txt" }; using (var repo = new Repository(repoPath)) @@ -976,7 +981,7 @@ public void CanCheckoutPaths() [Fact] public void CannotCheckoutPathsWithEmptyOrNullPathArgument() { - string repoPath = CloneStandardTestRepo(); + string repoPath = SandboxStandardTestRepo(); using (var repo = new Repository(repoPath)) { @@ -999,7 +1004,7 @@ public void CannotCheckoutPathsWithEmptyOrNullPathArgument() [InlineData("1.txt")] public void CanCheckoutPathFromCurrentBranch(string fileName) { - string repoPath = CloneStandardTestRepo(); + string repoPath = SandboxStandardTestRepo(); using (var repo = new Repository(repoPath)) { diff --git a/LibGit2Sharp.Tests/CherryPickFixture.cs b/LibGit2Sharp.Tests/CherryPickFixture.cs index 7afb3f033..c4b61455f 100644 --- a/LibGit2Sharp.Tests/CherryPickFixture.cs +++ b/LibGit2Sharp.Tests/CherryPickFixture.cs @@ -14,7 +14,7 @@ public class CherryPickFixture : BaseFixture [InlineData(false)] public void CanCherryPick(bool fromDetachedHead) { - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { if (fromDetachedHead) @@ -42,11 +42,11 @@ public void CherryPickWithConflictDoesNotCommit() const string secondBranchFileName = "second branch file.txt"; const string sharedBranchFileName = "first+second branch file.txt"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var firstBranch = repo.CreateBranch("FirstBranch"); - firstBranch.Checkout(); + repo.Checkout(firstBranch); // Commit with ONE new file to both first & second branch (SecondBranch is created on this commit). AddFileCommitToRepo(repo, sharedBranchFileName); @@ -56,7 +56,7 @@ public void CherryPickWithConflictDoesNotCommit() AddFileCommitToRepo(repo, firstBranchFileName); AddFileCommitToRepo(repo, sharedBranchFileName, "The first branches comment"); // Change file in first branch - secondBranch.Checkout(); + repo.Checkout(secondBranch); // Commit with ONE new file to second branch (FirstBranch and SecondBranch now point to separate commits that both have the same parent commit). AddFileCommitToRepo(repo, secondBranchFileName); AddFileCommitToRepo(repo, sharedBranchFileName, "The second branches comment"); // Change file in second branch @@ -83,7 +83,7 @@ public void CanSpecifyConflictFileStrategy(CheckoutFileConflictStrategy conflict const string conflictFile = "a.txt"; const string conflictBranchName = "conflicts"; - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { Branch branch = repo.Branches[conflictBranchName]; diff --git a/LibGit2Sharp.Tests/CleanFixture.cs b/LibGit2Sharp.Tests/CleanFixture.cs index 358000b94..f674285c6 100644 --- a/LibGit2Sharp.Tests/CleanFixture.cs +++ b/LibGit2Sharp.Tests/CleanFixture.cs @@ -9,7 +9,7 @@ public class CleanFixture : BaseFixture [Fact] public void CanCleanWorkingDirectory() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Verify that there are the expected number of entries and untracked files @@ -27,7 +27,8 @@ public void CanCleanWorkingDirectory() [Fact] public void CannotCleanABareRepository() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.RemoveUntrackedFiles()); } diff --git a/LibGit2Sharp.Tests/CloneFixture.cs b/LibGit2Sharp.Tests/CloneFixture.cs index a3b35d8b3..d291ddcdc 100644 --- a/LibGit2Sharp.Tests/CloneFixture.cs +++ b/LibGit2Sharp.Tests/CloneFixture.cs @@ -36,6 +36,26 @@ public void CanClone(string url) } } + [Theory] + [InlineData("br2", "a4a7dce85cf63874e984719f4fdd239f5145052f")] + [InlineData("packed", "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9")] + [InlineData("test", "e90810b8df3e80c413d903f631643c716887138d")] + public void CanCloneWithCheckoutBranchName(string branchName, string headTipId) + { + var scd = BuildSelfCleaningDirectory(); + + string clonedRepoPath = Repository.Clone(BareTestRepoPath, scd.DirectoryPath, new CloneOptions { BranchName = branchName }); + + using (var repo = new Repository(clonedRepoPath)) + { + var head = repo.Head; + + Assert.Equal(branchName, head.Name); + Assert.True(head.IsTracking); + Assert.Equal(headTipId, head.Tip.Sha); + } + } + private void AssertLocalClone(string url, string path = null, bool isCloningAnEmptyRepository = false) { var scd = BuildSelfCleaningDirectory(); @@ -59,7 +79,7 @@ private void AssertLocalClone(string url, string path = null, bool isCloningAnEm [Fact] public void CanCloneALocalRepositoryFromALocalUri() { - var uri = new Uri(BareTestRepoPath); + var uri = new Uri(Path.GetFullPath(BareTestRepoPath)); AssertLocalClone(uri.AbsoluteUri, BareTestRepoPath); } @@ -72,7 +92,7 @@ public void CanCloneALocalRepositoryFromAStandardPath() [Fact] public void CanCloneALocalRepositoryFromANewlyCreatedTemporaryPath() { - var path = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString().Substring(0, 8)); + var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); SelfCleaningDirectory scd = BuildSelfCleaningDirectory(path); Repository.Init(scd.DirectoryPath); AssertLocalClone(scd.DirectoryPath, isCloningAnEmptyRepository: true); @@ -126,6 +146,8 @@ public void WontCheckoutIfAskedNotTo(string url) public void CallsProgressCallbacks(string url) { bool transferWasCalled = false; + bool progressWasCalled = false; + bool updateTipsWasCalled = false; bool checkoutWasCalled = false; var scd = BuildSelfCleaningDirectory(); @@ -133,10 +155,14 @@ public void CallsProgressCallbacks(string url) Repository.Clone(url, scd.DirectoryPath, new CloneOptions() { OnTransferProgress = _ => { transferWasCalled = true; return true; }, + OnProgress = progress => { progressWasCalled = true; return true; }, + OnUpdateTips = (name, oldId, newId) => { updateTipsWasCalled = true; return true; }, OnCheckoutProgress = (a, b, c) => checkoutWasCalled = true }); Assert.True(transferWasCalled); + Assert.True(progressWasCalled); + Assert.True(updateTipsWasCalled); Assert.True(checkoutWasCalled); } @@ -173,8 +199,10 @@ public void CanCloneFromBBWithCredentials(string url, string user, string pass) { var scd = BuildSelfCleaningDirectory(); - string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath, new CloneOptions() { - CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials { + string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath, new CloneOptions() + { + CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials + { Username = user, Password = pass, } @@ -199,5 +227,20 @@ public void CloningAnUrlWithoutPathThrows() Assert.Throws(() => Repository.Clone("http://github.com", scd.DirectoryPath)); } + + [Theory] + [InlineData("git://github.com/libgit2/TestGitRepository")] + public void CloningWithoutWorkdirPathThrows(string url) + { + Assert.Throws(() => Repository.Clone(url, null)); + } + + [Fact] + public void CloningWithoutUrlThrows() + { + var scd = BuildSelfCleaningDirectory(); + + Assert.Throws(() => Repository.Clone(null, scd.DirectoryPath)); + } } } diff --git a/LibGit2Sharp.Tests/CommitAncestorFixture.cs b/LibGit2Sharp.Tests/CommitAncestorFixture.cs index fe83c1117..6ea6176b6 100644 --- a/LibGit2Sharp.Tests/CommitAncestorFixture.cs +++ b/LibGit2Sharp.Tests/CommitAncestorFixture.cs @@ -35,7 +35,8 @@ public class CommitAncestorFixture : BaseFixture [InlineData(null, "be3563a", "-")] public void FindCommonAncestorForTwoCommits(string result, string sha1, string sha2) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var first = sha1 == "-" ? CreateOrphanedCommit(repo) : repo.Lookup(sha1); var second = sha2 == "-" ? CreateOrphanedCommit(repo) : repo.Lookup(sha2); @@ -65,7 +66,8 @@ public void FindCommonAncestorForTwoCommits(string result, string sha1, string s [InlineData(null, new[] { "4c062a6", "-" }, MergeBaseFindingStrategy.Standard)] public void FindCommonAncestorForCommitsAsEnumerable(string result, string[] shas, MergeBaseFindingStrategy strategy) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commits = shas.Select(sha => sha == "-" ? CreateOrphanedCommit(repo) : repo.Lookup(sha)).ToArray(); @@ -88,7 +90,8 @@ public void FindCommonAncestorForCommitsAsEnumerable(string result, string[] sha [InlineData("0000000", "4c062a6")] public void FindCommonAncestorForTwoCommitsThrows(string sha1, string sha2) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var first = repo.Lookup(sha1); var second = repo.Lookup(sha2); @@ -104,7 +107,8 @@ public void FindCommonAncestorForTwoCommitsThrows(string sha1, string sha2) [InlineData(new[] { "4c062a6", "be3563a", "000000" }, MergeBaseFindingStrategy.Standard)] public void FindCommonAncestorForCommitsAsEnumerableThrows(string[] shas, MergeBaseFindingStrategy strategy) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commits = shas.Select(sha => sha == "-" ? CreateOrphanedCommit(repo) : repo.Lookup(sha)).ToArray(); diff --git a/LibGit2Sharp.Tests/CommitFixture.cs b/LibGit2Sharp.Tests/CommitFixture.cs index a4d7eca44..fa76f585f 100644 --- a/LibGit2Sharp.Tests/CommitFixture.cs +++ b/LibGit2Sharp.Tests/CommitFixture.cs @@ -17,7 +17,8 @@ public class CommitFixture : BaseFixture [Fact] public void CanCountCommits() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(7, repo.Commits.Count()); } @@ -26,7 +27,7 @@ public void CanCountCommits() [Fact] public void CanCorrectlyCountCommitsWhenSwitchingToAnotherBranch() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Hard reset and then remove untracked files @@ -47,7 +48,8 @@ public void CanCorrectlyCountCommitsWhenSwitchingToAnotherBranch() public void CanEnumerateCommits() { int count = 0; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { foreach (Commit commit in repo.Commits) { @@ -61,7 +63,7 @@ public void CanEnumerateCommits() [Fact] public void CanEnumerateCommitsInDetachedHeadState() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { ObjectId parentOfHead = repo.Head.Tip.Parents.First().Id; @@ -76,7 +78,8 @@ public void CanEnumerateCommitsInDetachedHeadState() [Fact] public void DefaultOrderingWhenEnumeratingCommitsIsTimeBased() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(CommitSortStrategies.Time, repo.Commits.SortedBy); } @@ -86,7 +89,8 @@ public void DefaultOrderingWhenEnumeratingCommitsIsTimeBased() public void CanEnumerateCommitsFromSha() { int count = 0; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f" })) { @@ -100,10 +104,11 @@ public void CanEnumerateCommitsFromSha() [Fact] public void QueryingTheCommitHistoryWithUnknownShaOrInvalidEntryPointThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { - Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = Constants.UnknownSha }).Count()); - Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = "refs/heads/deadbeef" }).Count()); + Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = Constants.UnknownSha }).Count()); + Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = "refs/heads/deadbeef" }).Count()); Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = null }).Count()); } } @@ -111,20 +116,21 @@ public void QueryingTheCommitHistoryWithUnknownShaOrInvalidEntryPointThrows() [Fact] public void QueryingTheCommitHistoryFromACorruptedReferenceThrows() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { CreateCorruptedDeadBeefHead(repo.Info.Path); - Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = repo.Branches["deadbeef"] }).Count()); - Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = repo.Refs["refs/heads/deadbeef"] }).Count()); + Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = repo.Branches["deadbeef"] }).Count()); + Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = repo.Refs["refs/heads/deadbeef"] }).Count()); } } [Fact] public void QueryingTheCommitHistoryWithBadParamsThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = string.Empty })); Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = null })); @@ -139,7 +145,8 @@ public void CanEnumerateCommitsWithReverseTimeSorting() reversedShas.Reverse(); int count = 0; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter { @@ -158,7 +165,8 @@ public void CanEnumerateCommitsWithReverseTimeSorting() [Fact] public void CanEnumerateCommitsWithReverseTopoSorting() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { List commits = repo.Commits.QueryBy(new CommitFilter { @@ -192,7 +200,8 @@ public void CanSimplifyByFirstParent() [Fact] public void CanGetParentsCount() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(1, repo.Commits.First().Parents.Count()); } @@ -202,7 +211,8 @@ public void CanGetParentsCount() public void CanEnumerateCommitsWithTimeSorting() { int count = 0; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter { @@ -221,7 +231,8 @@ public void CanEnumerateCommitsWithTimeSorting() [Fact] public void CanEnumerateCommitsWithTopoSorting() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { List commits = repo.Commits.QueryBy(new CommitFilter { @@ -255,7 +266,7 @@ public void CanEnumerateFromHead() [Fact] public void CanEnumerateFromDetachedHead() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repoClone = new Repository(path)) { // Hard reset and then remove untracked files @@ -364,7 +375,7 @@ public void CanEnumerateCommitsFromATagAnnotation() CanEnumerateCommitsFromATag(t => t.Annotation); } - private static void CanEnumerateCommitsFromATag(Func transformer) + private void CanEnumerateCommitsFromATag(Func transformer) { AssertEnumerationOfCommits( repo => new CommitFilter { Since = transformer(repo.Tags["test"]) }, @@ -400,7 +411,7 @@ public void CanEnumerateCommitsFromATagWhichPointsToABlob() [Fact] public void CanEnumerateCommitsFromATagWhichPointsToATree() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { string headTreeSha = repo.Head.Tip.Tree.Sha; @@ -413,9 +424,10 @@ public void CanEnumerateCommitsFromATagWhichPointsToATree() } } - private static void AssertEnumerationOfCommits(Func filterBuilder, IEnumerable abbrevIds) + private void AssertEnumerationOfCommits(Func filterBuilder, IEnumerable abbrevIds) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { AssertEnumerationOfCommitsInRepo(repo, filterBuilder, abbrevIds); } @@ -433,7 +445,8 @@ private static void AssertEnumerationOfCommitsInRepo(IRepository repo, Func(sha); Assert.Equal("testing\n", commit.Message); @@ -445,7 +458,8 @@ public void CanLookupCommitGeneric() [Fact] public void CanReadCommitData() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { GitObject obj = repo.Lookup(sha); Assert.NotNull(obj); @@ -476,7 +490,8 @@ public void CanReadCommitData() [Fact] public void CanReadCommitWithMultipleParents() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commit = repo.Lookup("a4a7dce85cf63874e984719f4fdd239f5145052f"); Assert.Equal(2, commit.Parents.Count()); @@ -486,7 +501,8 @@ public void CanReadCommitWithMultipleParents() [Fact] public void CanDirectlyAccessABlobOfTheCommit() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commit = repo.Lookup("4c062a6"); @@ -500,7 +516,8 @@ public void CanDirectlyAccessABlobOfTheCommit() [Fact] public void CanDirectlyAccessATreeOfTheCommit() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commit = repo.Lookup("4c062a6"); @@ -512,7 +529,8 @@ public void CanDirectlyAccessATreeOfTheCommit() [Fact] public void DirectlyAccessingAnUnknownTreeEntryOfTheCommitReturnsNull() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commit = repo.Lookup("4c062a6"); @@ -575,7 +593,7 @@ public void CanCommitWithSignatureFromConfig() [Fact] public void CommitParentsAreMergeHeads() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard, "c47800"); @@ -786,7 +804,7 @@ public void CanAmendARootCommit() [Fact] public void CanAmendACommitWithMoreThanOneParent() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var mergedCommit = repo.Lookup("be3563a"); @@ -813,7 +831,7 @@ public void CanAmendACommitWithMoreThanOneParent() private static void CreateAndStageANewFile(IRepository repo) { - string relativeFilepath = string.Format("new-file-{0}.txt", Guid.NewGuid()); + string relativeFilepath = string.Format("new-file-{0}.txt", Path.GetRandomFileName()); Touch(repo.Info.WorkingDirectory, relativeFilepath, "brand new content\n"); repo.Stage(relativeFilepath); } @@ -842,7 +860,7 @@ public void CanNotAmendAnEmptyRepository() [Fact] public void CanRetrieveChildrenOfASpecificCommit() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { const string parentSha = "5b5b025afb0b4c913b4c338a42934a3863bf3644"; @@ -874,7 +892,7 @@ from p in c.Parents [Fact] public void CanCorrectlyDistinguishAuthorFromCommitter() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var author = new Signature("Wilbert van Dolleweerd", "getit@xs4all.nl", @@ -914,7 +932,7 @@ public void CanCommitOnOrphanedBranch() [Fact] public void CanNotCommitAnEmptyCommit() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); @@ -927,7 +945,7 @@ public void CanNotCommitAnEmptyCommit() [Fact] public void CanCommitAnEmptyCommitWhenForced() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); @@ -941,7 +959,7 @@ public void CanCommitAnEmptyCommitWhenForced() [Fact] public void CanNotAmendAnEmptyCommit() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); @@ -958,7 +976,7 @@ public void CanNotAmendAnEmptyCommit() [Fact] public void CanAmendAnEmptyCommitWhenForced() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); @@ -976,7 +994,7 @@ public void CanAmendAnEmptyCommitWhenForced() [Fact] public void CanCommitAnEmptyCommitWhenMerging() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); @@ -997,7 +1015,7 @@ public void CanCommitAnEmptyCommitWhenMerging() [Fact] public void CanAmendAnEmptyMergeCommit() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); diff --git a/LibGit2Sharp.Tests/ConfigurationFixture.cs b/LibGit2Sharp.Tests/ConfigurationFixture.cs index ad085a5a0..edce94932 100644 --- a/LibGit2Sharp.Tests/ConfigurationFixture.cs +++ b/LibGit2Sharp.Tests/ConfigurationFixture.cs @@ -46,7 +46,7 @@ private static void AssertValueInGlobalConfigFile(string regex) [Fact] public void CanUnsetAnEntryFromTheLocalConfiguration() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.Null(repo.Config.Get("unittests.boolsetting")); @@ -67,7 +67,8 @@ public void CanUnsetAnEntryFromTheGlobalConfiguration() var options = BuildFakeConfigs(scd); - using (var repo = new Repository(BareTestRepoPath, options)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path, options)) { Assert.True(repo.Config.HasConfig(ConfigurationLevel.Global)); Assert.Equal(42, repo.Config.Get("Wow.Man-I-am-totally-global").Value); @@ -83,7 +84,8 @@ public void CanUnsetAnEntryFromTheGlobalConfiguration() [Fact] public void CanReadBooleanValue() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.True(repo.Config.Get("core.ignorecase").Value); Assert.True(repo.Config.GetValueOrDefault("core.ignorecase")); @@ -97,7 +99,8 @@ public void CanReadBooleanValue() [Fact] public void CanReadIntValue() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(2, repo.Config.Get("unittests.intsetting").Value); Assert.Equal(2, repo.Config.GetValueOrDefault("unittests.intsetting")); @@ -112,7 +115,8 @@ public void CanReadIntValue() [Fact] public void CanReadLongValue() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(15234, repo.Config.Get("unittests.longsetting").Value); Assert.Equal(15234, repo.Config.GetValueOrDefault("unittests.longsetting")); @@ -126,7 +130,8 @@ public void CanReadLongValue() [Fact] public void CanReadStringValue() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal("+refs/heads/*:refs/remotes/origin/*", repo.Config.Get("remote.origin.fetch").Value); Assert.Equal("+refs/heads/*:refs/remotes/origin/*", repo.Config.Get("remote", "origin", "fetch").Value); @@ -168,7 +173,8 @@ public void CanEnumerateGlobalConfig() string configPath = CreateConfigurationWithDummyUser(Constants.Signature); var options = new RepositoryOptions { GlobalConfigurationLocation = configPath }; - using (var repo = new Repository(StandardTestRepoPath, options)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path, options)) { var entry = repo.Config.FirstOrDefault>(e => e.Key == "user.name"); Assert.NotNull(entry); @@ -179,7 +185,8 @@ public void CanEnumerateGlobalConfig() [Fact] public void CanEnumerateLocalConfig() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var entry = repo.Config.FirstOrDefault>(e => e.Key == "core.ignorecase"); Assert.NotNull(entry); @@ -190,7 +197,8 @@ public void CanEnumerateLocalConfig() [Fact] public void CanEnumerateLocalConfigContainingAKeyWithNoValue() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var entry = repo.Config .Single>(c => c.Level == ConfigurationLevel.Local && c.Key == "core.pager"); @@ -202,7 +210,8 @@ public void CanEnumerateLocalConfigContainingAKeyWithNoValue() [Fact] public void CanFindInLocalConfig() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var matches = repo.Config.Find("unit"); @@ -218,7 +227,8 @@ public void CanFindInGlobalConfig() string configPath = CreateConfigurationWithDummyUser(Constants.Signature); var options = new RepositoryOptions { GlobalConfigurationLocation = configPath }; - using (var repo = new Repository(StandardTestRepoPath, options)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path, options)) { var matches = repo.Config.Find(@"\.name", ConfigurationLevel.Global); @@ -231,7 +241,7 @@ public void CanFindInGlobalConfig() [Fact] public void CanSetBooleanValue() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("unittests.boolsetting", true); @@ -252,7 +262,7 @@ public void SettingLocalConfigurationOutsideAReposThrows() [Fact] public void CanSetIntValue() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("unittests.intsetting", 3); @@ -264,7 +274,7 @@ public void CanSetIntValue() [Fact] public void CanSetLongValue() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("unittests.longsetting", (long)451); @@ -276,7 +286,7 @@ public void CanSetLongValue() [Fact] public void CanSetStringValue() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("unittests.stringsetting", "val"); @@ -288,7 +298,7 @@ public void CanSetStringValue() [Fact] public void CanSetAndReadUnicodeStringValue() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("unittests.stringsetting", "Juliën"); @@ -310,7 +320,8 @@ public void CanSetAndReadUnicodeStringValue() [Fact] public void ReadingUnsupportedTypeThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Config.Get("unittests.setting")); Assert.Throws(() => repo.Config.Get("unittests.setting")); @@ -320,7 +331,8 @@ public void ReadingUnsupportedTypeThrows() [Fact] public void ReadingValueThatDoesntExistReturnsNull() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Null(repo.Config.Get("unittests.ghostsetting")); Assert.Null(repo.Config.Get("unittests.ghostsetting")); @@ -332,7 +344,8 @@ public void ReadingValueThatDoesntExistReturnsNull() [Fact] public void SettingUnsupportedTypeThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Config.Set("unittests.setting", (short)123)); Assert.Throws(() => repo.Config.Set("unittests.setting", repo.Config)); @@ -346,7 +359,7 @@ public void CanGetAnEntryFromASpecificStore() var options = BuildFakeConfigs(scd); - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path, options)) { Assert.True(repo.Config.HasConfig(ConfigurationLevel.Local)); @@ -371,7 +384,8 @@ public void CanTellIfASpecificStoreContainsAKey() var options = BuildFakeConfigs(scd); - using (var repo = new Repository(BareTestRepoPath, options)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path, options)) { Assert.True(repo.Config.HasConfig(ConfigurationLevel.System)); diff --git a/LibGit2Sharp.Tests/ConflictFixture.cs b/LibGit2Sharp.Tests/ConflictFixture.cs index 148081c4c..af1663676 100644 --- a/LibGit2Sharp.Tests/ConflictFixture.cs +++ b/LibGit2Sharp.Tests/ConflictFixture.cs @@ -66,7 +66,7 @@ private static List RenameConflictData public void CanResolveConflictsByRemovingFromTheIndex( bool removeFromWorkdir, string filename, bool existsBeforeRemove, bool existsAfterRemove, FileStatus lastStatus, int removedIndexEntries) { - var path = CloneMergedTestRepo(); + var path = SandboxMergedTestRepo(); using (var repo = new Repository(path)) { int count = repo.Index.Count; @@ -92,7 +92,7 @@ public void CanResolveConflictsByRemovingFromTheIndex( [Fact] public void CanGetOriginalNamesOfRenameConflicts() { - var path = CloneMergeRenamesTestRepo(); + var path = Sandbox(MergeRenamesTestRepoWorkingDirPath); using (var repo = new Repository(path)) { var expected = RenameConflictData; @@ -115,7 +115,8 @@ public void CanGetOriginalNamesOfRenameConflicts() [Theory, PropertyData("ConflictData")] public void CanRetrieveSingleConflictByPath(string filepath, string ancestorId, string ourId, string theirId) { - using (var repo = new Repository(MergedTestRepoWorkingDirPath)) + var path = SandboxMergedTestRepo(); + using (var repo = new Repository(path)) { Conflict conflict = repo.Index.Conflicts[filepath]; Assert.NotNull(conflict); @@ -162,7 +163,8 @@ private string GetId(IndexEntry e) [Fact] public void CanRetrieveAllConflicts() { - using (var repo = new Repository(MergedTestRepoWorkingDirPath)) + var path = SandboxMergedTestRepo(); + using (var repo = new Repository(path)) { var expected = repo.Index.Conflicts.Select(c => new[] { GetPath(c), GetId(c.Ancestor), GetId(c.Ours), GetId(c.Theirs) }).ToArray(); Assert.Equal(expected, ConflictData); diff --git a/LibGit2Sharp.Tests/CurrentOperationFixture.cs b/LibGit2Sharp.Tests/CurrentOperationFixture.cs index 5b9200310..8944bbeb4 100644 --- a/LibGit2Sharp.Tests/CurrentOperationFixture.cs +++ b/LibGit2Sharp.Tests/CurrentOperationFixture.cs @@ -23,7 +23,8 @@ public void CurrentOperationIsNoneForNewRepo(bool isBare) [Fact] public void CurrentOperationInNoneForABareRepo() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(CurrentOperation.None, repo.Info.CurrentOperation); } @@ -41,7 +42,7 @@ public void CurrentOperationInNoneForABareRepo() [InlineData("rebase-merge/whatever", CurrentOperation.RebaseMerge)] public void CurrentOperationHasExpectedPendingOperationValues(string stateFile, CurrentOperation expectedState) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); Touch(Path.Combine(path, ".git"), stateFile); diff --git a/LibGit2Sharp.Tests/DescribeFixture.cs b/LibGit2Sharp.Tests/DescribeFixture.cs new file mode 100644 index 000000000..52e0ac8fc --- /dev/null +++ b/LibGit2Sharp.Tests/DescribeFixture.cs @@ -0,0 +1,53 @@ +using System.Linq; +using LibGit2Sharp.Tests.TestHelpers; +using Xunit; + +namespace LibGit2Sharp.Tests +{ + public class DescribeFixture : BaseFixture + { + [Fact] + public void CanDescribeACommit() + { + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) + { + // No annotated tags can be used to describe "master" + var masterTip = repo.Branches["master"].Tip; + Assert.Throws(() => repo.Describe(masterTip)); + Assert.Equal("4c062a6", repo.Describe(masterTip, + new DescribeOptions { UseCommitIdAsFallback = true })); + Assert.Equal("4c06", repo.Describe(masterTip, + new DescribeOptions { UseCommitIdAsFallback = true, MinimumCommitIdAbbreviatedSize = 2 })); + + // No lightweight tags can either be used to describe "master" + Assert.Throws(() => repo.Describe(masterTip, + new DescribeOptions{ Strategy = DescribeStrategy.Tags })); + + repo.ApplyTag("myTag", "5b5b025afb0b4c913b4c338a42934a3863bf3644"); + Assert.Equal("myTag-5-g4c062a6", repo.Describe(masterTip, + new DescribeOptions { Strategy = DescribeStrategy.Tags })); + Assert.Equal("myTag-5-g4c062a636", repo.Describe(masterTip, + new DescribeOptions { Strategy = DescribeStrategy.Tags, MinimumCommitIdAbbreviatedSize = 9 })); + Assert.Equal("myTag-4-gbe3563a", repo.Describe(masterTip.Parents.Single(), + new DescribeOptions { Strategy = DescribeStrategy.Tags })); + + Assert.Equal("heads/master", repo.Describe(masterTip, + new DescribeOptions { Strategy = DescribeStrategy.All })); + Assert.Equal("heads/packed-test-3-gbe3563a", repo.Describe(masterTip.Parents.Single(), + new DescribeOptions { Strategy = DescribeStrategy.All })); + + // "test" branch points to an annotated tag (also named "test") + // Let's rename the branch to ease the understanding of what we + // are exercising. + + repo.Branches.Rename(repo.Branches["test"], "ForLackOfABetterName"); + + var anotherTip = repo.Branches["ForLackOfABetterName"].Tip; + Assert.Equal("test", repo.Describe(anotherTip)); + Assert.Equal("test-0-g7b43849", repo.Describe(anotherTip, + new DescribeOptions{ AlwaysRenderLongFormat = true })); + } + } + } +} diff --git a/LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs b/LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs index c0711a468..00ef0ab2b 100644 --- a/LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs +++ b/LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs @@ -10,7 +10,8 @@ public class DiffBlobToBlobFixture : BaseFixture [Fact] public void ComparingABlobAgainstItselfReturnsNoDifference() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("7909961"); @@ -25,7 +26,8 @@ public void ComparingABlobAgainstItselfReturnsNoDifference() [Fact] public void CanCompareTwoVersionsOfABlobWithADiffOfTwoHunks() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var oldblob = repo.Lookup("7909961"); var newblob = repo.Lookup("4e935b7"); @@ -72,7 +74,7 @@ Blob CreateBinaryBlob(IRepository repo) [Fact] public void CanCompareATextualBlobAgainstABinaryBlob() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Blob binBlob = CreateBinaryBlob(repo); @@ -91,7 +93,8 @@ public void CanCompareATextualBlobAgainstABinaryBlob() [Fact] public void CanCompareABlobAgainstANullBlob() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("7909961"); @@ -112,7 +115,8 @@ public void CanCompareABlobAgainstANullBlob() [Fact] public void ComparingTwoNullBlobsReturnsAnEmptyContentChanges() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { ContentChanges changes = repo.Diff.Compare((Blob)null, (Blob)null); diff --git a/LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs b/LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs index 79055475f..b5de35e57 100644 --- a/LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs +++ b/LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs @@ -66,7 +66,8 @@ public void CanCompareASimpleTreeAgainstTheWorkDir() [Fact] public void CanCompareAMoreComplexTreeAgainstTheWorkdir() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -270,7 +271,8 @@ public void CanCompareASimpleTreeAgainstTheIndex() [Fact] public void CanCompareAMoreComplexTreeAgainstTheIndex() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -297,7 +299,8 @@ public void CanCompareAMoreComplexTreeAgainstTheIndex() [Fact] public void CanCompareASubsetofTheTreeAgainstTheIndex() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -321,7 +324,8 @@ private static void AssertCanCompareASubsetOfTheTreeAgainstTheIndex(TreeChanges [Fact] public void CanCompareASubsetofTheTreeAgainstTheIndexWithLaxExplicitPathsValidationAndANonExistentPath() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -338,7 +342,8 @@ public void CanCompareASubsetofTheTreeAgainstTheIndexWithLaxExplicitPathsValidat [Fact] public void ComparingASubsetofTheTreeAgainstTheIndexWithStrictExplicitPathsValidationAndANonExistentPathThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -402,7 +407,8 @@ public void CanCopeWithEndOfFileNewlineChanges() [Fact] public void ComparingATreeInABareRepositoryAgainstTheWorkDirOrTheIndexThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws( () => repo.Diff.Compare(repo.Head.Tip.Tree, DiffTargets.WorkingDirectory)); diff --git a/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs b/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs index 2ba238f4f..99603b69e 100644 --- a/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs +++ b/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs @@ -15,7 +15,8 @@ public class DiffTreeToTreeFixture : BaseFixture [Fact] public void ComparingATreeAgainstItselfReturnsNoDifference() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -31,7 +32,8 @@ public void ComparingATreeAgainstItselfReturnsNoDifference() [Fact] public void RetrievingANonExistentFileChangeReturnsNull() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -49,7 +51,8 @@ public void RetrievingANonExistentFileChangeReturnsNull() [Fact] public void CanCompareACommitTreeAgainstItsParent() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree commitTree = repo.Head.Tip.Tree; Tree parentCommitTree = repo.Head.Tip.Parents.Single().Tree; @@ -89,7 +92,7 @@ static void CreateBinaryFile(string path) [Fact] public void CanDetectABinaryChange() { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { const string filename = "binfile.foo"; var filepath = Path.Combine(repo.Info.WorkingDirectory, filename); @@ -115,7 +118,7 @@ public void CanDetectABinaryChange() [Fact] public void CanDetectABinaryDeletion() { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { const string filename = "binfile.foo"; var filepath = Path.Combine(repo.Info.WorkingDirectory, filename); @@ -151,7 +154,8 @@ public void CanDetectABinaryDeletion() [Fact] public void CanCompareASubsetofTheTreeAgainstOneOfItsAncestor() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; Tree ancestor = repo.Lookup("9fd738e").Tree; @@ -181,7 +185,8 @@ public void CanCompareASubsetofTheTreeAgainstOneOfItsAncestor() [Fact] public void CanCompareACommitTreeAgainstATreeWithNoCommonAncestor() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree commitTree = repo.Head.Tip.Tree; Tree commitTreeWithDifferentAncestor = repo.Branches["refs/remotes/origin/test"].Tip.Tree; @@ -206,7 +211,8 @@ public void CanCompareACommitTreeAgainstATreeWithNoCommonAncestor() [Fact] public void CanCompareATreeAgainstAnotherTreeWithLaxExplicitPathsValidationAndNonExistentPath() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree commitTree = repo.Head.Tip.Tree; Tree commitTreeWithDifferentAncestor = repo.Branches["refs/remotes/origin/test"].Tip.Tree; @@ -224,7 +230,8 @@ public void CanCompareATreeAgainstAnotherTreeWithLaxExplicitPathsValidationAndNo [Fact] public void ComparingATreeAgainstAnotherTreeWithStrictExplicitPathsValidationThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree commitTree = repo.Head.Tip.Tree; Tree commitTreeWithDifferentAncestor = repo.Branches["refs/remotes/origin/test"].Tip.Tree; @@ -256,7 +263,8 @@ public void ComparingATreeAgainstAnotherTreeWithStrictExplicitPathsValidationThr [Fact] public void DetectsTheRenamingOfAModifiedFileByDefault() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree rootCommitTree = repo.Lookup("f8d44d7").Tree; Tree commitTreeWithRenamedFile = repo.Lookup("4be51d6").Tree; @@ -771,7 +779,8 @@ public void CanDetectTheExactRenamingExactCopyingOfNonModifiedAndModifiedFilesWh [InlineData(4, 193)] public void CanCompareTwoVersionsOfAFileWithATrailingNewlineDeletion(int contextLines, int expectedPatchLength) { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree rootCommitTree = repo.Lookup("f8d44d7").Tree; Tree commitTreeWithUpdatedFile = repo.Lookup("ec9e401").Tree; @@ -866,7 +875,8 @@ public void CanCompareTwoVersionsOfAFileWithADiffOfTwoHunks(int contextLines, in Similarity = SimilarityOptions.None, }; - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree rootCommitTree = repo.Lookup("f8d44d7").Tree; Tree mergedCommitTree = repo.Lookup("7252fe2").Tree; @@ -964,7 +974,8 @@ public void CanHandleTwoTreeEntryChangesWithTheSamePath() [Fact] public void CanCompareATreeAgainstANullTree() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Branches["refs/remotes/origin/test"].Tip.Tree; @@ -987,7 +998,8 @@ public void CanCompareATreeAgainstANullTree() [Fact] public void ComparingTwoNullTreesReturnsAnEmptyTreeChanges() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var changes = repo.Diff.Compare(default(Tree), default(Tree)); @@ -1000,7 +1012,7 @@ public void ComparingReliesOnProvidedConfigEntriesIfAny() { const string file = "1/branch_file.txt"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { TreeEntry entry = repo.Head[file]; @@ -1100,7 +1112,8 @@ public void RetrievingDiffChangesMustAlwaysBeCaseSensitive() [Fact] public void CallingCompareWithAnUnsupportedGenericParamThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Diff.Compare(default(Tree), default(Tree))); Assert.Throws(() => repo.Diff.Compare()); diff --git a/LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs b/LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs index fd0a34b44..c16fd9882 100644 --- a/LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs +++ b/LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs @@ -30,7 +30,8 @@ public class DiffWorkdirToIndexFixture : BaseFixture [Fact] public void CanCompareTheWorkDirAgainstTheIndex() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var changes = repo.Diff.Compare(); @@ -45,7 +46,8 @@ public void CanCompareTheWorkDirAgainstTheIndex() [InlineData("really-i-cant-exist.txt", FileStatus.Nonexistent)] public void CanCompareTheWorkDirAgainstTheIndexWithLaxUnmatchedExplicitPathsValidation(string relativePath, FileStatus currentStatus) { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); @@ -62,7 +64,8 @@ public void CanCompareTheWorkDirAgainstTheIndexWithLaxUnmatchedExplicitPathsVali [InlineData("really-i-cant-exist.txt", FileStatus.Nonexistent)] public void ComparingTheWorkDirAgainstTheIndexWithStrictUnmatchedExplicitPathsValidationAndANonExistentPathspecThrows(string relativePath, FileStatus currentStatus) { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); @@ -77,7 +80,8 @@ public void CallbackForUnmatchedExplicitPathsIsCalledWhenSet(string relativePath { var callback = new AssertUnmatchedPathspecsCallbackIsCalled(); - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); @@ -105,7 +109,7 @@ public void ComparingReliesOnProvidedConfigEntriesIfAny() { const string file = "1/branch_file.txt"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { TreeEntry entry = repo.Head[file]; @@ -171,7 +175,8 @@ private RepositoryOptions BuildFakeSystemConfigFilemodeOption( [Fact] public void CanCompareTheWorkDirAgainstTheIndexWithUntrackedFiles() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var changes = repo.Diff.Compare(null, true); diff --git a/LibGit2Sharp.Tests/FetchFixture.cs b/LibGit2Sharp.Tests/FetchFixture.cs index b9a4048a7..945a20015 100644 --- a/LibGit2Sharp.Tests/FetchFixture.cs +++ b/LibGit2Sharp.Tests/FetchFixture.cs @@ -16,7 +16,9 @@ public class FetchFixture : BaseFixture [InlineData("git://github.com/libgit2/TestGitRepository.git")] public void CanFetchIntoAnEmptyRepository(string url) { - using (var repo = InitIsolatedRepository()) + string path = InitNewRepository(); + + using (var repo = new Repository(path)) { Remote remote = repo.Network.Remotes.Add(remoteName, url); @@ -53,7 +55,9 @@ public void CanFetchIntoAnEmptyRepositoryWithCredentials() InconclusiveIf(() => string.IsNullOrEmpty(Constants.PrivateRepoUrl), "Populate Constants.PrivateRepo* to run this test"); - using (var repo = InitIsolatedRepository()) + string path = InitNewRepository(); + + using (var repo = new Repository(path)) { Remote remote = repo.Network.Remotes.Add(remoteName, Constants.PrivateRepoUrl); @@ -71,7 +75,9 @@ public void CanFetchIntoAnEmptyRepositoryWithCredentials() [InlineData("git://github.com/libgit2/TestGitRepository.git")] public void CanFetchAllTagsIntoAnEmptyRepository(string url) { - using (var repo = InitIsolatedRepository()) + string path = InitNewRepository(); + + using (var repo = new Repository(path)) { Remote remote = repo.Network.Remotes.Add(remoteName, url); @@ -80,12 +86,18 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url) TestRemoteInfo remoteInfo = TestRemoteInfo.TestRemoteInstance; var expectedFetchState = new ExpectedFetchState(remoteName); - // Add expected tags only as no branches are expected to be fetched + // Add expected tags foreach (KeyValuePair kvp in remoteInfo.Tags) { expectedFetchState.AddExpectedTag(kvp.Key, ObjectId.Zero, kvp.Value); } + // Add expected branch objects + foreach (KeyValuePair kvp in remoteInfo.BranchTips) + { + expectedFetchState.AddExpectedBranch(kvp.Key, ObjectId.Zero, kvp.Value); + } + // Perform the actual fetch repo.Network.Fetch(remote, new FetchOptions { TagFetchMode = TagFetchMode.All, @@ -96,7 +108,7 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url) expectedFetchState.CheckUpdatedReferences(repo); // Verify the reflog entries - Assert.Equal(0, repo.Refs.Log(string.Format("refs/remotes/{0}/master", remoteName)).Count()); // Only tags are retrieved + Assert.Equal(1, repo.Refs.Log(string.Format("refs/remotes/{0}/master", remoteName)).Count()); // Branches are also retrieved } } @@ -106,7 +118,9 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url) [InlineData("git://github.com/libgit2/TestGitRepository.git", "master", "first-merge")] public void CanFetchCustomRefSpecsIntoAnEmptyRepository(string url, string localBranchName, string remoteBranchName) { - using (var repo = InitIsolatedRepository()) + string path = InitNewRepository(); + + using (var repo = new Repository(path)) { Remote remote = repo.Network.Remotes.Add(remoteName, url); @@ -133,15 +147,17 @@ public void CanFetchCustomRefSpecsIntoAnEmptyRepository(string url, string local } } - [Theory(Skip = "Skipping due to recent github handling modification of --include-tag.")] + [Theory] [InlineData(TagFetchMode.All, 4)] [InlineData(TagFetchMode.None, 0)] - [InlineData(TagFetchMode.Auto, 3)] + //[InlineData(TagFetchMode.Auto, 3)] // TODO: Skipping due to github modification of --include-tag handling." public void FetchRespectsConfiguredAutoTagSetting(TagFetchMode tagFetchMode, int expectedTagCount) { string url = "http://github.com/libgit2/TestGitRepository"; - using (var repo = InitIsolatedRepository()) + string path = InitNewRepository(); + + using (var repo = new Repository(path)) { Remote remote = repo.Network.Remotes.Add(remoteName, url); Assert.NotNull(remote); @@ -157,5 +173,20 @@ public void FetchRespectsConfiguredAutoTagSetting(TagFetchMode tagFetchMode, int Assert.Equal(expectedTagCount, repo.Tags.Count()); } } + + [Fact] + public void CanFetchAllTagsAfterAnInitialClone() + { + var scd = BuildSelfCleaningDirectory(); + + const string url = "https://github.com/libgit2/TestGitRepository"; + + string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath); + + using (var repo = new Repository(clonedRepoPath)) + { + repo.Fetch("origin", new FetchOptions { TagFetchMode = TagFetchMode.All }); + } + } } } diff --git a/LibGit2Sharp.Tests/FilterBranchFixture.cs b/LibGit2Sharp.Tests/FilterBranchFixture.cs index bdfb137ee..dfe14329e 100644 --- a/LibGit2Sharp.Tests/FilterBranchFixture.cs +++ b/LibGit2Sharp.Tests/FilterBranchFixture.cs @@ -15,7 +15,7 @@ public class FilterBranchFixture : BaseFixture public FilterBranchFixture() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); repo = new Repository(path); } diff --git a/LibGit2Sharp.Tests/GlobalSettingsFixture.cs b/LibGit2Sharp.Tests/GlobalSettingsFixture.cs index d8533f035..28d0b12c5 100644 --- a/LibGit2Sharp.Tests/GlobalSettingsFixture.cs +++ b/LibGit2Sharp.Tests/GlobalSettingsFixture.cs @@ -1,4 +1,5 @@ -using System.Text.RegularExpressions; +using System; +using System.Text.RegularExpressions; using LibGit2Sharp.Tests.TestHelpers; using Xunit; @@ -26,26 +27,31 @@ public void CanRetrieveValidVersionString() string versionInfo = GlobalSettings.Version.ToString(); // The GlobalSettings.Version returned string should contain : - // version:'0.17.0' LibGit2Sharp version number. + // version: '0.17.0[.198[-pre]]' LibGit2Sharp version number. // git2SharpHash:'unknown' ( when compiled from source ) else LibGit2Sharp library hash. // git2hash: '06d772d' LibGit2 library hash. // arch: 'x86' or 'amd64' LibGit2 target. // git2Features: 'Threads, Ssh' LibGit2 features compiled with. - string regex = @"^(?\d{1,}\.\d{1,2}\.\d{1,3})-(?\w+)-(?\w+) \((?\w+) - (?(?:\w*(?:, )*\w+)*)\)$"; + string regex = @"^(?\d{1,}\.\d{1,2}\.\d{1,3}(\.\d{1,5}(-pre)?)?)-(?\w+)-(?\w+) \((?\w+) - (?(?:\w*(?:, )*\w+)*)\)$"; Assert.NotNull(versionInfo); Match regexResult = Regex.Match(versionInfo, regex); Assert.True(regexResult.Success, "The following version string format is enforced:" + - "Major.Minor.Patch-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features)"); + "Major.Minor.Patch[.Build['-pre']]-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features)"); GroupCollection matchGroups = regexResult.Groups; // Check that all groups are valid - foreach (Group group in matchGroups) + for (int i = 0; i < matchGroups.Count; i++) { - Assert.True(group.Success); + if (i == 1 || i == 2) // Build number and '-pre' are optional + { + continue; + } + + Assert.True(matchGroups[i].Success); } } } diff --git a/LibGit2Sharp.Tests/IgnoreFixture.cs b/LibGit2Sharp.Tests/IgnoreFixture.cs index 523a08c8b..790336512 100644 --- a/LibGit2Sharp.Tests/IgnoreFixture.cs +++ b/LibGit2Sharp.Tests/IgnoreFixture.cs @@ -11,7 +11,7 @@ public class IgnoreFixture : BaseFixture [Fact] public void TemporaryRulesShouldApplyUntilCleared() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Touch(repo.Info.WorkingDirectory, "Foo.cs", "Bar"); @@ -31,7 +31,7 @@ public void TemporaryRulesShouldApplyUntilCleared() [Fact] public void IsPathIgnoredShouldVerifyWhetherPathIsIgnored() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Touch(repo.Info.WorkingDirectory, "Foo.cs", "Bar"); @@ -51,7 +51,8 @@ public void IsPathIgnoredShouldVerifyWhetherPathIsIgnored() [Fact] public void CallingIsPathIgnoredWithBadParamsThrows() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Ignore.IsPathIgnored(string.Empty)); Assert.Throws(() => repo.Ignore.IsPathIgnored(null)); @@ -61,7 +62,8 @@ public void CallingIsPathIgnoredWithBadParamsThrows() [Fact] public void AddingATemporaryRuleWithBadParamsThrows() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Ignore.AddTemporaryRules(null)); } @@ -70,7 +72,7 @@ public void AddingATemporaryRuleWithBadParamsThrows() [Fact] public void CanCheckIfAPathIsIgnoredUsingThePreferedPlatformDirectorySeparatorChar() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Touch(repo.Info.WorkingDirectory, ".gitignore", "/NewFolder\n/NewFolder/NewFolder"); diff --git a/LibGit2Sharp.Tests/IndexFixture.cs b/LibGit2Sharp.Tests/IndexFixture.cs index a1ec882a3..8dcdc4037 100644 --- a/LibGit2Sharp.Tests/IndexFixture.cs +++ b/LibGit2Sharp.Tests/IndexFixture.cs @@ -28,7 +28,8 @@ public class IndexFixture : BaseFixture [Fact] public void CanCountEntriesInIndex() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(expectedEntries.Count(), repo.Index.Count); } @@ -37,7 +38,8 @@ public void CanCountEntriesInIndex() [Fact] public void CanEnumerateIndex() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(expectedEntries, repo.Index.Select(e => e.Path).OrderBy(p => p, StringComparer.Ordinal).ToArray()); @@ -47,7 +49,8 @@ public void CanEnumerateIndex() [Fact] public void CanFetchAnIndexEntryByItsName() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { IndexEntry entry = repo.Index["README"]; Assert.Equal("README", entry.Path); @@ -65,7 +68,8 @@ public void CanFetchAnIndexEntryByItsName() [Fact] public void FetchingAnUnknownIndexEntryReturnsNull() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { IndexEntry entry = repo.Index["I-do-not-exist.txt"]; Assert.Null(entry); @@ -75,7 +79,8 @@ public void FetchingAnUnknownIndexEntryReturnsNull() [Fact] public void ReadIndexWithBadParamsFails() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Throws(() => { IndexEntry entry = repo.Index[null]; }); Assert.Throws(() => { IndexEntry entry = repo.Index[string.Empty]; }); @@ -139,7 +144,7 @@ public void CanRenameAFile() [InlineData("modified_unstaged_file.txt", FileStatus.Modified, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Removed, FileStatus.Staged)] public void CanMoveAnExistingFileOverANonExistingFile(string sourcePath, FileStatus sourceStatus, string destPath, FileStatus destStatus, FileStatus sourcePostStatus, FileStatus destPostStatus) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.Equal(sourceStatus, repo.RetrieveStatus(sourcePath)); @@ -178,9 +183,10 @@ public void MovingAFileNotInTheWorkingDirectoryThrows(string sourcePath, FileSta InvalidMoveUseCases(sourcePath, sourceStatus, destPaths); } - private static void InvalidMoveUseCases(string sourcePath, FileStatus sourceStatus, IEnumerable destPaths) + private void InvalidMoveUseCases(string sourcePath, FileStatus sourceStatus, IEnumerable destPaths) { - using (var repo = new Repository(StandardTestRepoPath)) + var repoPath = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(repoPath)) { Assert.Equal(sourceStatus, repo.RetrieveStatus(sourcePath)); @@ -224,7 +230,8 @@ public void PathsOfIndexEntriesAreExpressedInNativeFormat() [Fact] public void CanReadIndexEntryAttributes() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(Mode.NonExecutableFile, repo.Index["README"].Mode); Assert.Equal(Mode.ExecutableFile, repo.Index["1/branch_file.txt"].Mode); @@ -282,7 +289,7 @@ public void CanCopeWithExternalChangesToTheIndex() [Fact] public void CanResetFullyMergedIndexFromTree() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); const string testFile = "new_tracked_file.txt"; @@ -313,7 +320,7 @@ public void CanResetFullyMergedIndexFromTree() [Fact] public void CanResetIndexWithUnmergedEntriesFromTree() { - string path = CloneMergedTestRepo(); + string path = SandboxMergedTestRepo(); const string testFile = "one.txt"; @@ -344,7 +351,7 @@ public void CanResetIndexWithUnmergedEntriesFromTree() [Fact] public void CanClearTheIndex() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); const string testFile = "1.txt"; // It is sufficient to check just one of the stage area changes, such as the modified file, @@ -366,5 +373,123 @@ public void CanClearTheIndex() Assert.Equal(FileStatus.Removed | FileStatus.Untracked, repo.RetrieveStatus(testFile)); } } + + [Theory] + [InlineData("new_tracked_file.txt", FileStatus.Added, FileStatus.Untracked)] + [InlineData("modified_staged_file.txt", FileStatus.Staged, FileStatus.Removed | FileStatus.Untracked)] + [InlineData("i_dont_exist.txt", FileStatus.Nonexistent, FileStatus.Nonexistent)] + public void CanRemoveAnEntryFromTheIndex(string pathInTheIndex, FileStatus expectedBeforeStatus, FileStatus expectedAfterStatus) + { + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) + { + var before = repo.RetrieveStatus(pathInTheIndex); + Assert.Equal(expectedBeforeStatus, before); + + repo.Index.Remove(pathInTheIndex); + + var after = repo.RetrieveStatus(pathInTheIndex); + Assert.Equal(expectedAfterStatus, after); + } + } + + [Theory] + [InlineData("new_untracked_file.txt", FileStatus.Untracked, FileStatus.Added)] + [InlineData("modified_unstaged_file.txt", FileStatus.Modified, FileStatus.Staged)] + public void CanAddAnEntryToTheIndexFromAFileInTheWorkdir(string pathInTheWorkdir, FileStatus expectedBeforeStatus, FileStatus expectedAfterStatus) + { + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) + { + var before = repo.RetrieveStatus(pathInTheWorkdir); + Assert.Equal(expectedBeforeStatus, before); + + repo.Index.Add(pathInTheWorkdir); + + var after = repo.RetrieveStatus(pathInTheWorkdir); + Assert.Equal(expectedAfterStatus, after); + } + } + + [Fact] + public void CanAddAnEntryToTheIndexFromABlob() + { + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) + { + const string targetIndexEntryPath = "1.txt"; + var before = repo.RetrieveStatus(targetIndexEntryPath); + Assert.Equal(FileStatus.Unaltered, before); + + var blob = repo.Lookup("a8233120f6ad708f843d861ce2b7228ec4e3dec6"); + + repo.Index.Add(blob, targetIndexEntryPath, Mode.NonExecutableFile); + + var after = repo.RetrieveStatus(targetIndexEntryPath); + Assert.Equal(FileStatus.Staged | FileStatus.Modified, after); + } + } + + [Fact] + public void AddingAnEntryToTheIndexFromAUnknwonFileInTheWorkdirThrows() + { + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) + { + const string filePath = "i_dont_exist.txt"; + var before = repo.RetrieveStatus(filePath); + Assert.Equal(FileStatus.Nonexistent, before); + + Assert.Throws(() => repo.Index.Add(filePath)); + } + } + + [Fact] + public void CanMimicGitAddAll() + { + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) + { + var before = repo.RetrieveStatus(); + Assert.True(before.Any(se => se.State == FileStatus.Untracked)); + Assert.True(before.Any(se => se.State == FileStatus.Modified)); + Assert.True(before.Any(se => se.State == FileStatus.Missing)); + + AddSomeCornerCases(repo); + + repo.Stage("*"); + + var after = repo.RetrieveStatus(); + Assert.False(after.Any(se => se.State == FileStatus.Untracked)); + Assert.False(after.Any(se => se.State == FileStatus.Modified)); + Assert.False(after.Any(se => se.State == FileStatus.Missing)); + } + } + + [Fact] + public void RetrievingAssumedUnchangedMarkedIndexEntries() + { + var path = SandboxAssumeUnchangedTestRepo(); + using (var repo = new Repository(path)) + { + var regularFile = repo.Index["hello.txt"]; + Assert.False(regularFile.AssumeUnchanged); + + var assumeUnchangedFile = repo.Index["world.txt"]; + Assert.True(assumeUnchangedFile.AssumeUnchanged); + } + } + + private static void AddSomeCornerCases(Repository repo) + { + // Turn 1.txt into a directory in the Index + repo.Index.Remove("1.txt"); + var blob = repo.Lookup("a8233120f6ad708f843d861ce2b7228ec4e3dec6"); + repo.Index.Add(blob, "1.txt/Sneaky", Mode.NonExecutableFile); + + // Turn README into a symlink + Blob linkContent = OdbHelper.CreateBlob(repo, "1.txt/sneaky"); + repo.Index.Add(linkContent, "README", Mode.SymbolicLink); + } } } diff --git a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj index b631e0275..37e7ec73d 100644 --- a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj +++ b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj @@ -1,5 +1,6 @@  + Debug AnyCPU @@ -22,7 +23,6 @@ TRACE;DEBUG;NET40 prompt 4 - pdbonly @@ -31,31 +31,21 @@ TRACE prompt 4 - - - - true - full - false - bin\Leaks\ - TRACE;DEBUG;NET40;LEAKS - prompt - 4 - - + False - ..\Lib\MoQ\Moq.dll + ..\packages\Moq.4.2.1409.1722\lib\net40\Moq.dll - - ..\Lib\xUnit\xunit.dll + + False + ..\packages\xunit.1.9.2\lib\net20\xunit.dll - ..\Lib\xUnit\xunit.extensions.dll + ..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll @@ -63,6 +53,7 @@ + @@ -135,15 +126,27 @@ LibGit2Sharp + + + + $(MSBuildProjectDirectory)\..\Lib\NativeBinaries - + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + $(DefineConstants);$(ExtraDefine) + + diff --git a/LibGit2Sharp/FetchOptions.cs b/LibGit2Sharp/FetchOptions.cs index 020f47f45..ec42a2d6e 100644 --- a/LibGit2Sharp/FetchOptions.cs +++ b/LibGit2Sharp/FetchOptions.cs @@ -6,7 +6,7 @@ namespace LibGit2Sharp /// /// Collection of parameters controlling Fetch behavior. /// - public sealed class FetchOptions + public sealed class FetchOptions : FetchOptionsBase { /// /// Specifies the tag-following behavior of the fetch operation. @@ -19,29 +19,5 @@ public sealed class FetchOptions /// retrieved during this fetch will be retrieved as well). /// public TagFetchMode? TagFetchMode { get; set; } - - /// - /// Delegate that progress updates of the network transfer portion of fetch - /// will be reported through. - /// - public ProgressHandler OnProgress { get; set; } - - /// - /// Delegate that updates of remote tracking branches will be reported through. - /// - public UpdateTipsHandler OnUpdateTips { get; set; } - - /// - /// Callback method that transfer progress will be reported through. - /// - /// Reports the client's state regarding the received and processed (bytes, objects) from the server. - /// - /// - public TransferProgressHandler OnTransferProgress { get; set; } - - /// - /// Handler to generate for authentication. - /// - public CredentialsHandler CredentialsProvider { get; set; } } } diff --git a/LibGit2Sharp/FetchOptionsBase.cs b/LibGit2Sharp/FetchOptionsBase.cs new file mode 100644 index 000000000..c2f2aeb44 --- /dev/null +++ b/LibGit2Sharp/FetchOptionsBase.cs @@ -0,0 +1,37 @@ +using LibGit2Sharp.Handlers; + +namespace LibGit2Sharp +{ + /// + /// Base collection of parameters controlling Fetch behavior. + /// + public abstract class FetchOptionsBase + { + internal FetchOptionsBase() + { + } + + /// + /// Handler for network transfer and indexing progress information. + /// + public ProgressHandler OnProgress { get; set; } + + /// + /// Handler for updates to remote tracking branches. + /// + public UpdateTipsHandler OnUpdateTips { get; set; } + + /// + /// Handler for data transfer progress. + /// + /// Reports the client's state regarding the received and processed (bytes, objects) from the server. + /// + /// + public TransferProgressHandler OnTransferProgress { get; set; } + + /// + /// Handler to generate for authentication. + /// + public CredentialsHandler CredentialsProvider { get; set; } + } +} diff --git a/LibGit2Sharp/GitObjectMetadata.cs b/LibGit2Sharp/GitObjectMetadata.cs new file mode 100644 index 000000000..b62e5ebea --- /dev/null +++ b/LibGit2Sharp/GitObjectMetadata.cs @@ -0,0 +1,35 @@ +using LibGit2Sharp.Core; +using System; + +namespace LibGit2Sharp +{ + /// + /// Exposes low level Git object metadata + /// + public sealed class GitObjectMetadata + { + private readonly GitObjectType type; + + /// + /// Size of the Object + /// + public long Size { get; private set; } + + /// + /// Object Type + /// + public ObjectType Type + { + get + { + return type.ToObjectType(); + } + } + + internal GitObjectMetadata(long size, GitObjectType type) + { + this.Size = size; + this.type = type; + } + } +} diff --git a/LibGit2Sharp/GlobalSettings.cs b/LibGit2Sharp/GlobalSettings.cs index 190cfadf4..b6ea82454 100644 --- a/LibGit2Sharp/GlobalSettings.cs +++ b/LibGit2Sharp/GlobalSettings.cs @@ -1,6 +1,5 @@ using System; using LibGit2Sharp.Core; -using LibGit2Sharp.Handlers; namespace LibGit2Sharp { @@ -13,17 +12,6 @@ public static class GlobalSettings private static LogConfiguration logConfiguration = LogConfiguration.None; - /// - /// Returns all the optional features that were compiled into - /// libgit2. - /// - /// A enumeration. - [Obsolete("This method will be removed in the next release. Use Version.Features instead.")] - public static BuiltInFeatures Features() - { - return Version.Features; - } - /// /// Returns information related to the current LibGit2Sharp /// library. @@ -44,7 +32,7 @@ public static Version Version /// with the server This is not commonly /// used: some callers may want to re-use an existing connection to /// perform fetch / push operations to a remote. - /// + /// /// Note that this configuration is global to an entire process /// and does not honor application domains. /// @@ -109,7 +97,7 @@ public static LogConfiguration LogConfiguration } else { - Proxy.git_trace_set(value.Level, value.GitTraceHandler); + Proxy.git_trace_set(value.Level, value.GitTraceCallback); Log.Write(LogLevel.Info, "Logging enabled at level {0}", value.Level); } diff --git a/LibGit2Sharp/IRepository.cs b/LibGit2Sharp/IRepository.cs index a68bdb862..ad3f2d78a 100644 --- a/LibGit2Sharp/IRepository.cs +++ b/LibGit2Sharp/IRepository.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using LibGit2Sharp.Handlers; namespace LibGit2Sharp { @@ -366,5 +365,23 @@ public interface IRepository : IDisposable /// If set, the options that control the status investigation. /// A holding the state of all the files. RepositoryStatus RetrieveStatus(StatusOptions options); + + /// + /// Finds the most recent annotated tag that is reachable from a commit. + /// + /// If the tag points to the commit, then only the tag is shown. Otherwise, + /// it suffixes the tag name with the number of additional commits on top + /// of the tagged object and the abbreviated object name of the most recent commit. + /// + /// + /// Optionally, the parameter allow to tweak the + /// search strategy (considering lightweith tags, or even branches as reference points) + /// and the formatting of the returned identifier. + /// + /// + /// The commit to be described. + /// Determines how the commit will be described. + /// A descriptive identifier for the commit based on the nearest annotated tag. + string Describe(Commit commit, DescribeOptions options); } } diff --git a/LibGit2Sharp/Index.cs b/LibGit2Sharp/Index.cs index 5e9e941a0..3c29db985 100644 --- a/LibGit2Sharp/Index.cs +++ b/LibGit2Sharp/Index.cs @@ -127,149 +127,6 @@ IEnumerator IEnumerable.GetEnumerator() #endregion - /// - /// Promotes to the staging area the latest modifications of a file in the working directory (addition, updation or removal). - /// - /// If this path is ignored by configuration then it will not be staged unless is unset. - /// - /// The path of the file within the working directory. - /// If set, determines how paths will be staged. - [Obsolete("This method will be removed in the next release. Use IRepository.Stage() instead.")] - public virtual void Stage(string path, StageOptions stageOptions = null) - { - repo.Stage(path, stageOptions); - } - - /// - /// Promotes to the staging area the latest modifications of a collection of files in the working directory (addition, updation or removal). - /// - /// Any paths (even those listed explicitly) that are ignored by configuration will not be staged unless is unset. - /// - /// The collection of paths of the files within the working directory. - /// If set, determines how paths will be staged. - [Obsolete("This method will be removed in the next release. Use IRepository.Stage() instead.")] - public virtual void Stage(IEnumerable paths, StageOptions stageOptions = null) - { - repo.Stage(paths, stageOptions); - } - - /// - /// Removes from the staging area all the modifications of a file since the latest commit (addition, updation or removal). - /// - /// The path of the file within the working directory. - /// - /// If set, the passed will be treated as explicit paths. - /// Use these options to determine how unmatched explicit paths should be handled. - /// - [Obsolete("This method will be removed in the next release. Use IRepository.Unstage() instead.")] - public virtual void Unstage(string path, ExplicitPathsOptions explicitPathsOptions = null) - { - repo.Unstage(path, explicitPathsOptions); - } - - /// - /// Removes from the staging area all the modifications of a collection of file since the latest commit (addition, updation or removal). - /// - /// The collection of paths of the files within the working directory. - /// - /// If set, the passed will be treated as explicit paths. - /// Use these options to determine how unmatched explicit paths should be handled. - /// - [Obsolete("This method will be removed in the next release. Use IRepository.Unstage() instead.")] - public virtual void Unstage(IEnumerable paths, ExplicitPathsOptions explicitPathsOptions = null) - { - repo.Unstage(paths, explicitPathsOptions); - } - - /// - /// Moves and/or renames a file in the working directory and promotes the change to the staging area. - /// - /// The path of the file within the working directory which has to be moved/renamed. - /// The target path of the file within the working directory. - [Obsolete("This method will be removed in the next release. Use IRepository.Move() instead.")] - public virtual void Move(string sourcePath, string destinationPath) - { - repo.Move(new[] { sourcePath }, new[] { destinationPath }); - } - - /// - /// Moves and/or renames a collection of files in the working directory and promotes the changes to the staging area. - /// - /// The paths of the files within the working directory which have to be moved/renamed. - /// The target paths of the files within the working directory. - [Obsolete("This method will be removed in the next release. Use IRepository.Move() instead.")] - public virtual void Move(IEnumerable sourcePaths, IEnumerable destinationPaths) - { - repo.Move(sourcePaths, destinationPaths); - } - - /// - /// Removes a file from the staging area, and optionally removes it from the working directory as well. - /// - /// If the file has already been deleted from the working directory, this method will only deal - /// with promoting the removal to the staging area. - /// - /// - /// The default behavior is to remove the file from the working directory as well. - /// - /// - /// When not passing a , the passed path will be treated as - /// a pathspec. You can for example use it to pass the relative path to a folder inside the working directory, - /// so that all files beneath this folders, and the folder itself, will be removed. - /// - /// - /// The path of the file within the working directory. - /// True to remove the file from the working directory, False otherwise. - /// - /// If set, the passed will be treated as an explicit path. - /// Use these options to determine how unmatched explicit paths should be handled. - /// - [Obsolete("This method will be removed in the next release. Use IRepository.Remove() instead.")] - public virtual void Remove(string path, bool removeFromWorkingDirectory = true, ExplicitPathsOptions explicitPathsOptions = null) - { - repo.Remove(new[] { path }, removeFromWorkingDirectory, explicitPathsOptions); - } - - /// - /// Removes a collection of fileS from the staging, and optionally removes them from the working directory as well. - /// - /// If a file has already been deleted from the working directory, this method will only deal - /// with promoting the removal to the staging area. - /// - /// - /// The default behavior is to remove the files from the working directory as well. - /// - /// - /// When not passing a , the passed paths will be treated as - /// a pathspec. You can for example use it to pass the relative paths to folders inside the working directory, - /// so that all files beneath these folders, and the folders themselves, will be removed. - /// - /// - /// The collection of paths of the files within the working directory. - /// True to remove the files from the working directory, False otherwise. - /// - /// If set, the passed will be treated as explicit paths. - /// Use these options to determine how unmatched explicit paths should be handled. - /// - [Obsolete("This method will be removed in the next release. Use IRepository.Remove() instead.")] - public virtual void Remove(IEnumerable paths, bool removeFromWorkingDirectory = true, ExplicitPathsOptions explicitPathsOptions = null) - { - repo.Remove(paths, removeFromWorkingDirectory, explicitPathsOptions); - } - - /// - /// Replaces entries in the staging area with entries from the specified tree. - /// - /// This overwrites all existing state in the staging area. - /// - /// - /// The to read the entries from. - [Obsolete("This method will be removed in the next release. Use Replace instead.")] - public virtual void Reset(Tree source) - { - Replace(source); - } - /// /// Replaces entries in the staging area with entries from the specified tree. /// @@ -300,38 +157,80 @@ public virtual void Clear() UpdatePhysicalIndex(); } - private string RemoveFromIndex(string relativePath) + private void RemoveFromIndex(string relativePath) { Proxy.git_index_remove_bypath(handle, relativePath); - - return relativePath; } - private void UpdatePhysicalIndex() + /// + /// Removes a specified entry from the index. + /// + /// The path of the entry to be removed. + public virtual void Remove(string indexEntryPath) { - Proxy.git_index_write(handle); + if (indexEntryPath == null) + { + throw new ArgumentNullException("indexEntryPath"); + } + + RemoveFromIndex(indexEntryPath); + + UpdatePhysicalIndex(); } /// - /// Retrieves the state of a file in the working directory, comparing it against the staging area and the latest commmit. + /// Adds a file from the workdir in the . + /// + /// If an entry with the same path already exists in the , + /// the newly added one will overwrite it. + /// /// - /// The relative path within the working directory to the file. - /// A representing the state of the parameter. - [Obsolete("This method will be removed in the next release. Use IRepository.RetrieveStatus() instead.")] - public virtual FileStatus RetrieveStatus(string filePath) + /// The path, in the working directory, of the file to be added. + public virtual void Add(string pathInTheWorkdir) { - return repo.RetrieveStatus(filePath); + if (pathInTheWorkdir == null) + { + throw new ArgumentNullException("pathInTheWorkdir"); + } + + Proxy.git_index_add_bypath(handle, pathInTheWorkdir); + + UpdatePhysicalIndex(); } /// - /// Retrieves the state of all files in the working directory, comparing them against the staging area and the latest commmit. + /// Adds an entry in the from a . + /// + /// If an entry with the same path already exists in the , + /// the newly added one will overwrite it. + /// /// - /// If set, the options that control the status investigation. - /// A holding the state of all the files. - [Obsolete("This method will be removed in the next release. Use IRepository.RetrieveStatus() instead.")] - public virtual RepositoryStatus RetrieveStatus(StatusOptions options = null) + /// The which content should be added to the . + /// The path to be used in the . + /// Either , + /// or . + public virtual void Add(Blob blob, string indexEntryPath, Mode indexEntryMode) + { + Ensure.ArgumentConformsTo(indexEntryMode, m => m.HasAny(TreeEntryDefinition.BlobModes), "indexEntryMode"); + + if (blob == null) + { + throw new ArgumentNullException("blob"); + } + + if (indexEntryPath == null) + { + throw new ArgumentNullException("indexEntryPath"); + } + + AddEntryToTheIndex(indexEntryPath, blob.Id, indexEntryMode); + + UpdatePhysicalIndex(); + } + + private void UpdatePhysicalIndex() { - return repo.RetrieveStatus(options); + Proxy.git_index_write(handle); } internal void Replace(TreeChanges changes) @@ -350,7 +249,11 @@ internal void Replace(TreeChanges changes) case ChangeKind.Deleted: /* Fall through */ case ChangeKind.Modified: - ReplaceIndexEntryWith(treeEntryChanges); + AddEntryToTheIndex( + treeEntryChanges.OldPath, + treeEntryChanges.OldOid, + treeEntryChanges.OldMode); + continue; default: @@ -372,13 +275,13 @@ public virtual ConflictCollection Conflicts } } - private void ReplaceIndexEntryWith(TreeEntryChanges treeEntryChanges) + private void AddEntryToTheIndex(string path, ObjectId id, Mode mode) { var indexEntry = new GitIndexEntry { - Mode = (uint)treeEntryChanges.OldMode, - Id = treeEntryChanges.OldOid.Oid, - Path = StrictFilePathMarshaler.FromManaged(treeEntryChanges.OldPath), + Mode = (uint)mode, + Id = id.Oid, + Path = StrictFilePathMarshaler.FromManaged(path), }; Proxy.git_index_add(handle, indexEntry); diff --git a/LibGit2Sharp/IndexEntry.cs b/LibGit2Sharp/IndexEntry.cs index d6e97eb03..7dc6b0150 100644 --- a/LibGit2Sharp/IndexEntry.cs +++ b/LibGit2Sharp/IndexEntry.cs @@ -30,6 +30,11 @@ public class IndexEntry : IEquatable /// public virtual StageLevel StageLevel { get; private set; } + /// + /// Whether the file is marked as assume-unchanged + /// + public virtual bool AssumeUnchanged { get; private set; } + /// /// Gets the id of the pointed at by this index entry. /// @@ -51,7 +56,8 @@ internal static IndexEntry BuildFromPtr(IndexEntrySafeHandle handle) Path = path.Native, Id = entry.Id, StageLevel = Proxy.git_index_entry_stage(handle), - Mode = (Mode)entry.Mode + Mode = (Mode)entry.Mode, + AssumeUnchanged = (GitIndexEntry.GIT_IDXENTRY_VALID & entry.Flags) == GitIndexEntry.GIT_IDXENTRY_VALID }; } diff --git a/LibGit2Sharp/InvalidSpecificationException.cs b/LibGit2Sharp/InvalidSpecificationException.cs index 5113f8c63..7c82a4372 100644 --- a/LibGit2Sharp/InvalidSpecificationException.cs +++ b/LibGit2Sharp/InvalidSpecificationException.cs @@ -5,7 +5,10 @@ namespace LibGit2Sharp { /// - /// The exception that is thrown when the provided specification is syntactically incorrect. + /// The exception that is thrown when a provided specification is bad. This + /// can happen if the provided specification is syntactically incorrect, or + /// if the spec refers to an object of an incorrect type (e.g. asking to + /// create a branch from a blob, or peeling a blob to a commit). /// [Serializable] public class InvalidSpecificationException : LibGit2SharpException diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 5d302db71..a2e6e616d 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -38,18 +38,6 @@ false bin\Release\LibGit2Sharp.xml - - true - full - false - bin\Leaks\ - TRACE;DEBUG;NET40;LEAKS - prompt - 4 - false - true - AllRules.ruleset - @@ -80,10 +68,16 @@ + + + + + + @@ -106,8 +100,10 @@ + + @@ -142,6 +138,8 @@ + + @@ -215,7 +213,6 @@ - @@ -354,16 +351,20 @@ + + $(MSBuildProjectDirectory)\..\Lib\NativeBinaries + + + + \ No newline at end of file diff --git a/LibGit2Sharp/Log.cs b/LibGit2Sharp/Log.cs index 23f79d93e..f8303fa01 100644 --- a/LibGit2Sharp/Log.cs +++ b/LibGit2Sharp/Log.cs @@ -1,7 +1,4 @@ -using System.Runtime.CompilerServices; -using LibGit2Sharp.Core; - -namespace LibGit2Sharp +namespace LibGit2Sharp { internal class Log { diff --git a/LibGit2Sharp/LogConfiguration.cs b/LibGit2Sharp/LogConfiguration.cs index f31eeac18..67c974bdf 100644 --- a/LibGit2Sharp/LogConfiguration.cs +++ b/LibGit2Sharp/LogConfiguration.cs @@ -27,6 +27,9 @@ public LogConfiguration(LogLevel level, LogHandler handler) Level = level; Handler = handler; + + // Explicitly create (and hold a reference to) a callback-delegate to wrap GitTraceHandler(). + GitTraceCallback = GitTraceHandler; } private LogConfiguration() @@ -35,8 +38,14 @@ private LogConfiguration() internal LogLevel Level { get; private set; } internal LogHandler Handler { get; private set; } + internal NativeMethods.git_trace_cb GitTraceCallback { get; private set; } - internal void GitTraceHandler(LogLevel level, IntPtr msg) + /// + /// This private method will be called from LibGit2 (from C code via + /// the GitTraceCallback delegate) to route LibGit2 log messages to + /// the same LogHandler as LibGit2Sharp messages. + /// + private void GitTraceHandler(LogLevel level, IntPtr msg) { string message = LaxUtf8Marshaler.FromNative(msg); Handler(level, message); diff --git a/LibGit2Sharp/Network.cs b/LibGit2Sharp/Network.cs index e473f0d74..05ab5fa19 100644 --- a/LibGit2Sharp/Network.cs +++ b/LibGit2Sharp/Network.cs @@ -52,11 +52,11 @@ public virtual IEnumerable ListReferences(Remote remote, Creden { Ensure.ArgumentNotNull(remote, "remote"); - using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true)) + using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true)) { if (credentialsProvider != null) { - var callbacks = new RemoteCallbacks(null, null, null, credentialsProvider); + var callbacks = new RemoteCallbacks(credentialsProvider); GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks(); Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks); } @@ -100,8 +100,7 @@ static void DoFetch(RemoteSafeHandle remoteHandle, FetchOptions options, Signatu Proxy.git_remote_set_autotag(remoteHandle, options.TagFetchMode.Value); } - var callbacks = new RemoteCallbacks( - options.OnProgress, options.OnTransferProgress, options.OnUpdateTips, options.CredentialsProvider); + var callbacks = new RemoteCallbacks(options); GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks(); // It is OK to pass the reference to the GitCallbacks directly here because libgit2 makes a copy of @@ -130,7 +129,7 @@ public virtual void Fetch(Remote remote, FetchOptions options = null, { Ensure.ArgumentNotNull(remote, "remote"); - using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true)) + using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true)) { DoFetch(remoteHandle, options, signature.OrDefault(repository.Config), logMessage); } @@ -151,7 +150,7 @@ public virtual void Fetch(Remote remote, IEnumerable refspecs, FetchOpti Ensure.ArgumentNotNull(remote, "remote"); Ensure.ArgumentNotNull(refspecs, "refspecs"); - using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true)) + using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true)) { Proxy.git_remote_set_fetch_refspecs(remoteHandle, refspecs); @@ -249,14 +248,6 @@ public virtual void Push( Ensure.ArgumentNotNull(remote, "remote"); Ensure.ArgumentNotNull(pushRefSpecs, "pushRefSpecs"); - // The following local variables are protected from garbage collection - // by a GC.KeepAlive call at the end of the method. Otherwise, - // random crashes during push progress reporting could occur. - PushTransferCallbacks pushTransferCallbacks; - PackbuilderCallbacks packBuilderCallbacks; - NativeMethods.git_push_transfer_progress pushProgress; - NativeMethods.git_packbuilder_progress packBuilderProgress; - // Return early if there is nothing to push. if (!pushRefSpecs.Any()) { @@ -268,65 +259,28 @@ public virtual void Push( pushOptions = new PushOptions(); } - PushCallbacks pushStatusUpdates = new PushCallbacks(pushOptions.OnPushStatusError); - // Load the remote. - using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true)) + using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true)) { - var callbacks = new RemoteCallbacks( - null, null, null, pushOptions.CredentialsProvider); + var callbacks = new RemoteCallbacks(pushOptions); GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks(); Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks); try { Proxy.git_remote_connect(remoteHandle, GitDirection.Push); - - // Perform the actual push. - using (PushSafeHandle pushHandle = Proxy.git_push_new(remoteHandle)) - { - pushTransferCallbacks = new PushTransferCallbacks(pushOptions.OnPushTransferProgress); - packBuilderCallbacks = new PackbuilderCallbacks(pushOptions.OnPackBuilderProgress); - - pushProgress = pushTransferCallbacks.GenerateCallback(); - packBuilderProgress = packBuilderCallbacks.GenerateCallback(); - - Proxy.git_push_set_callbacks(pushHandle, pushProgress, packBuilderProgress); - - // Set push options. - Proxy.git_push_set_options(pushHandle, - new GitPushOptions() - { - PackbuilderDegreeOfParallelism = pushOptions.PackbuilderDegreeOfParallelism - }); - - // Add refspecs. - foreach (string pushRefSpec in pushRefSpecs) - { - Proxy.git_push_add_refspec(pushHandle, pushRefSpec); - } - - Proxy.git_push_finish(pushHandle); - - if (!Proxy.git_push_unpack_ok(pushHandle)) + Proxy.git_remote_push(remoteHandle, pushRefSpecs, + new GitPushOptions() { - throw new LibGit2SharpException("Push failed - remote did not successfully unpack."); - } - - Proxy.git_push_status_foreach(pushHandle, pushStatusUpdates.Callback); - Proxy.git_push_update_tips(pushHandle, signature.OrDefault(repository.Config), logMessage); - } + PackbuilderDegreeOfParallelism = pushOptions.PackbuilderDegreeOfParallelism + }, + signature.OrDefault(repository.Config), logMessage); } finally { Proxy.git_remote_disconnect(remoteHandle); } } - - GC.KeepAlive(pushProgress); - GC.KeepAlive(packBuilderProgress); - GC.KeepAlive(pushTransferCallbacks); - GC.KeepAlive(packBuilderCallbacks); } /// @@ -369,46 +323,5 @@ internal virtual IEnumerable FetchHeads (name, url, oid, isMerge) => new FetchHead(repository, name, url, oid, isMerge, i++)); } } - - /// - /// Helper class to handle callbacks during push. - /// - private class PushCallbacks - { - readonly PushStatusErrorHandler onError; - - public PushCallbacks(PushStatusErrorHandler onError) - { - this.onError = onError; - } - - public int Callback(IntPtr referenceNamePtr, IntPtr msgPtr, IntPtr payload) - { - // Exit early if there is no callback. - if (onError == null) - { - return 0; - } - - // The reference name pointer should never be null - if it is, - // this indicates a bug somewhere (libgit2, server, etc). - if (referenceNamePtr == IntPtr.Zero) - { - Proxy.giterr_set_str(GitErrorCategory.Invalid, "Not expecting null for reference name in push status."); - return -1; - } - - // Only report updates where there is a message - indicating - // that there was an error. - if (msgPtr != IntPtr.Zero) - { - string referenceName = LaxUtf8Marshaler.FromNative(referenceNamePtr); - string msg = LaxUtf8Marshaler.FromNative(msgPtr); - onError(new PushStatusError(referenceName, msg)); - } - - return 0; - } - } } } diff --git a/LibGit2Sharp/NoteCollection.cs b/LibGit2Sharp/NoteCollection.cs index 678ffdeac..6a2a947cb 100644 --- a/LibGit2Sharp/NoteCollection.cs +++ b/LibGit2Sharp/NoteCollection.cs @@ -186,7 +186,7 @@ public virtual Note Add(ObjectId targetId, string message, Signature author, Sig Remove(targetId, author, committer, @namespace); - Proxy.git_note_create(repo.Handle, author, committer, canonicalNamespace, targetId, message, true); + Proxy.git_note_create(repo.Handle, canonicalNamespace, author, committer, targetId, message, true); return this[canonicalNamespace, targetId]; } diff --git a/LibGit2Sharp/ObjectDatabase.cs b/LibGit2Sharp/ObjectDatabase.cs index 9398855fc..c3c38f5ec 100644 --- a/LibGit2Sharp/ObjectDatabase.cs +++ b/LibGit2Sharp/ObjectDatabase.cs @@ -72,6 +72,20 @@ public virtual bool Contains(ObjectId objectId) return Proxy.git_odb_exists(handle, objectId); } + /// + /// Retrieves the header of a GitObject from the object database. The header contains the Size + /// and Type of the object. Note that most backends do not support reading only the header + /// of an object, so the whole object will be read and then size would be returned. + /// + /// Object Id of the queried object + /// GitObjectMetadata object instance containg object header information + public virtual GitObjectMetadata RetrieveObjectMetadata(ObjectId objectId) + { + Ensure.ArgumentNotNull(objectId, "objectId"); + + return Proxy.git_odb_read_header(handle, objectId); + } + /// /// Inserts a into the object database, created from the content of a file. /// diff --git a/LibGit2Sharp/PeelException.cs b/LibGit2Sharp/PeelException.cs new file mode 100644 index 000000000..e7fbfe796 --- /dev/null +++ b/LibGit2Sharp/PeelException.cs @@ -0,0 +1,55 @@ +using System; +using System.Runtime.Serialization; +using LibGit2Sharp.Core; + +namespace LibGit2Sharp +{ + /// + /// The exception that is thrown when a tag cannot be peeled to the + /// target type due to the object model. + /// + [Serializable] + public class PeelException : LibGit2SharpException + { + /// + /// Initializes a new instance of the class. + /// + public PeelException() + { + } + + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A message that describes the error. + public PeelException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. + /// + /// The error message that explains the reason for the exception. + /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. + public PeelException(string message, Exception innerException) + : base(message, innerException) + { + } + + /// + /// Initializes a new instance of the class with a serialized data. + /// + /// The that holds the serialized object data about the exception being thrown. + /// The that contains contextual information about the source or destination. + protected PeelException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + + internal PeelException(string message, GitErrorCode code, GitErrorCategory category) + : base(message, code, category) + { + } + } +} diff --git a/LibGit2Sharp/Properties/AssemblyInfo.cs b/LibGit2Sharp/Properties/AssemblyInfo.cs index f46068872..c0a9f3da4 100644 --- a/LibGit2Sharp/Properties/AssemblyInfo.cs +++ b/LibGit2Sharp/Properties/AssemblyInfo.cs @@ -42,5 +42,6 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.20.2")] -[assembly: AssemblyFileVersion("0.20.2")] +[assembly: AssemblyVersion("0.21.0")] +[assembly: AssemblyFileVersion("0.21.0")] +[assembly: AssemblyInformationalVersion("0.21.0")] diff --git a/LibGit2Sharp/Reference.cs b/LibGit2Sharp/Reference.cs index 8ab7d1b78..5b0787ede 100644 --- a/LibGit2Sharp/Reference.cs +++ b/LibGit2Sharp/Reference.cs @@ -25,17 +25,6 @@ public abstract class Reference : IEquatable, IBelongToARepository protected Reference() { } - /// - /// Initializes a new instance of the class. - /// - /// The canonical name. - /// The target identifier. - [Obsolete("This ctor will be removed in a future release.")] - protected Reference(string canonicalName, string targetIdentifier) - : this(null, canonicalName, targetIdentifier) - { - } - /// /// This would be protected+internal, were that supported by C#. /// Do not use except in subclasses. diff --git a/LibGit2Sharp/ReferenceCollection.cs b/LibGit2Sharp/ReferenceCollection.cs index a6d89c9e0..a564e82b9 100644 --- a/LibGit2Sharp/ReferenceCollection.cs +++ b/LibGit2Sharp/ReferenceCollection.cs @@ -142,34 +142,6 @@ public virtual void Remove(Reference reference) Proxy.git_reference_remove(repo.Handle, reference.CanonicalName); } - /// - /// Rename an existing reference with a new name, and update the reflog - /// - /// The reference to rename. - /// The new canonical name. - /// Identity used for updating the reflog. - /// Message added to the reflog. - /// True to allow silent overwriting a potentially existing reference, false otherwise. - /// A new . - [Obsolete("This method will be removed in the next release. Please use Rename() instead.")] - public virtual Reference Move(Reference reference, string newName, Signature signature, string logMessage = null, bool allowOverwrite = false) - { - return Rename(reference, newName, signature, logMessage, allowOverwrite); - } - - /// - /// Rename an existing reference with a new name - /// - /// The reference to rename. - /// The new canonical name. - /// True to allow silent overwriting a potentially existing reference, false otherwise. - /// A new . - [Obsolete("This method will be removed in the next release. Please use Rename() instead.")] - public virtual Reference Move(Reference reference, string newName, bool allowOverwrite = false) - { - return Rename(reference, newName, null, null, allowOverwrite); - } - /// /// Rename an existing reference with a new name, and update the reflog /// diff --git a/LibGit2Sharp/ReferenceCollectionExtensions.cs b/LibGit2Sharp/ReferenceCollectionExtensions.cs index 962a5af94..34c2a6623 100644 --- a/LibGit2Sharp/ReferenceCollectionExtensions.cs +++ b/LibGit2Sharp/ReferenceCollectionExtensions.cs @@ -124,23 +124,6 @@ public static Reference UpdateTarget(this ReferenceCollection refsColl, Referenc return UpdateTarget(refsColl, directRef, objectish, null, null); } - /// - /// Rename an existing reference with a new name - /// - /// The canonical name of the reference to rename. - /// The new canonical name. - /// The identity used for updating the reflog - /// The optional message to log in the - /// True to allow silent overwriting a potentially existing reference, false otherwise. - /// The being worked with. - /// A new . - [Obsolete("This method will be removed in the next release. Please use Rename() instead.")] - public static Reference Move(this ReferenceCollection refsColl, string currentName, string newName, - Signature signature = null, string logMessage = null, bool allowOverwrite = false) - { - return refsColl.Rename(currentName, newName, signature, logMessage, allowOverwrite); - } - /// /// Rename an existing reference with a new name /// diff --git a/LibGit2Sharp/Remote.cs b/LibGit2Sharp/Remote.cs index bb6de70ff..7884342be 100644 --- a/LibGit2Sharp/Remote.cs +++ b/LibGit2Sharp/Remote.cs @@ -88,7 +88,7 @@ public virtual IEnumerable PushRefSpecs /// The transformed reference. internal string FetchSpecTransformToSource(string reference) { - using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, Name, true)) + using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, Name, true)) { GitRefSpecHandle fetchSpecPtr = Proxy.git_remote_get_refspec(remoteHandle, 0); return Proxy.git_refspec_rtransform(fetchSpecPtr, reference); diff --git a/LibGit2Sharp/RemoteCallbacks.cs b/LibGit2Sharp/RemoteCallbacks.cs index b2540dfbd..fe068b5b9 100644 --- a/LibGit2Sharp/RemoteCallbacks.cs +++ b/LibGit2Sharp/RemoteCallbacks.cs @@ -12,18 +12,36 @@ namespace LibGit2Sharp /// internal class RemoteCallbacks { - internal RemoteCallbacks( - ProgressHandler onProgress = null, - TransferProgressHandler onDownloadProgress = null, - UpdateTipsHandler onUpdateTips = null, - CredentialsHandler credentialsProvider = null) + internal RemoteCallbacks(CredentialsHandler credentialsProvider) { - Progress = onProgress; - DownloadTransferProgress = onDownloadProgress; - UpdateTips = onUpdateTips; CredentialsProvider = credentialsProvider; } + internal RemoteCallbacks(PushOptions pushOptions) + { + if (pushOptions == null) + { + return; + } + + PushTransferProgress = pushOptions.OnPushTransferProgress; + PackBuilderProgress = pushOptions.OnPackBuilderProgress; + CredentialsProvider = pushOptions.CredentialsProvider; + } + + internal RemoteCallbacks(FetchOptionsBase fetchOptions) + { + if (fetchOptions == null) + { + return; + } + + Progress = fetchOptions.OnProgress; + DownloadTransferProgress = fetchOptions.OnTransferProgress; + UpdateTips = fetchOptions.OnUpdateTips; + CredentialsProvider = fetchOptions.CredentialsProvider; + } + #region Delegates /// @@ -42,6 +60,16 @@ internal RemoteCallbacks( /// private readonly TransferProgressHandler DownloadTransferProgress; + /// + /// Push transfer progress callback. + /// + private readonly PushTransferProgressHandler PushTransferProgress; + + /// + /// Pack builder creation progress callback. + /// + private readonly PackBuilderProgressHandler PackBuilderProgress; + #endregion /// @@ -73,6 +101,16 @@ internal GitRemoteCallbacks GenerateCallbacks() callbacks.download_progress = GitDownloadTransferProgressHandler; } + if (PushTransferProgress != null) + { + callbacks.push_transfer_progress = GitPushTransferProgressHandler; + } + + if (PackBuilderProgress != null) + { + callbacks.pack_progress = GitPackbuilderProgressHandler; + } + return callbacks; } @@ -144,6 +182,30 @@ private int GitDownloadTransferProgressHandler(ref GitTransferProgress progress, return Proxy.ConvertResultToCancelFlag(shouldContinue); } + private int GitPushTransferProgressHandler(uint current, uint total, UIntPtr bytes, IntPtr payload) + { + bool shouldContinue = true; + + if (PushTransferProgress != null) + { + shouldContinue = PushTransferProgress((int)current, (int)total, (long)bytes); + } + + return Proxy.ConvertResultToCancelFlag(shouldContinue); + } + + private int GitPackbuilderProgressHandler(int stage, uint current, uint total, IntPtr payload) + { + bool shouldContinue = true; + + if (PackBuilderProgress != null) + { + shouldContinue = PackBuilderProgress((PackBuilderStage)stage, (int)current, (int)total); + } + + return Proxy.ConvertResultToCancelFlag(shouldContinue); + } + private int GitCredentialHandler(out IntPtr ptr, IntPtr cUrl, IntPtr usernameFromUrl, GitCredentialType credTypes, IntPtr payload) { string url = LaxUtf8Marshaler.FromNative(cUrl); diff --git a/LibGit2Sharp/RemoteCollection.cs b/LibGit2Sharp/RemoteCollection.cs index 491e2d874..b0eb584a9 100644 --- a/LibGit2Sharp/RemoteCollection.cs +++ b/LibGit2Sharp/RemoteCollection.cs @@ -43,7 +43,7 @@ internal Remote RemoteForName(string name, bool shouldThrowIfNotFound = true) { Ensure.ArgumentNotNull(name, "name"); - using (RemoteSafeHandle handle = Proxy.git_remote_load(repository.Handle, name, shouldThrowIfNotFound)) + using (RemoteSafeHandle handle = Proxy.git_remote_lookup(repository.Handle, name, shouldThrowIfNotFound)) { return handle == null ? null : Remote.BuildFromPtr(handle, this.repository); } diff --git a/LibGit2Sharp/RemoteUpdater.cs b/LibGit2Sharp/RemoteUpdater.cs index 0ad7559ea..550eb15bf 100644 --- a/LibGit2Sharp/RemoteUpdater.cs +++ b/LibGit2Sharp/RemoteUpdater.cs @@ -28,7 +28,7 @@ internal RemoteUpdater(Repository repo, Remote remote) fetchRefSpecs = new UpdatingCollection(GetFetchRefSpecs, SetFetchRefSpecs); pushRefSpecs = new UpdatingCollection(GetPushRefSpecs, SetPushRefSpecs); - remoteHandle = Proxy.git_remote_load(repo.Handle, remote.Name, true); + remoteHandle = Proxy.git_remote_lookup(repo.Handle, remote.Name, true); } private IEnumerable GetFetchRefSpecs() diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs index 1c81bd26d..7348a1dc9 100644 --- a/LibGit2Sharp/Repository.cs +++ b/LibGit2Sharp/Repository.cs @@ -23,7 +23,7 @@ public sealed class Repository : IRepository private readonly CommitLog commits; private readonly Lazy config; private readonly RepositorySafeHandle handle; - private readonly Index index; + private readonly Lazy index; private readonly ReferenceCollection refs; private readonly TagCollection tags; private readonly StashCollection stashes; @@ -76,7 +76,10 @@ public Repository(string path, RepositoryOptions options = null) "When overriding the opening of a bare repository, both RepositoryOptions.WorkingDirectoryPath an RepositoryOptions.IndexPath have to be provided."); } - isBare = false; + if (!isWorkDirNull) + { + isBare = false; + } if (!isIndexNull) { @@ -95,7 +98,7 @@ public Repository(string path, RepositoryOptions options = null) if (!isBare) { - index = indexBuilder(); + index = new Lazy(() => indexBuilder()); } commits = new CommitLog(this); @@ -117,7 +120,7 @@ public Repository(string path, RepositoryOptions options = null) pathCase = new Lazy(() => new PathCase(this)); submodules = new SubmoduleCollection(this); - EagerlyLoadTheConfigIfAnyPathHaveBeenPassed(options); + EagerlyLoadComponentsWithSpecifiedPaths(options); } catch { @@ -150,26 +153,33 @@ static public bool IsValid(string path) return true; } - private void EagerlyLoadTheConfigIfAnyPathHaveBeenPassed(RepositoryOptions options) + private void EagerlyLoadComponentsWithSpecifiedPaths(RepositoryOptions options) { if (options == null) { return; } - if (options.GlobalConfigurationLocation == null && - options.XdgConfigurationLocation == null && - options.SystemConfigurationLocation == null) + if (options.GlobalConfigurationLocation != null || + options.XdgConfigurationLocation != null || + options.SystemConfigurationLocation != null) { - return; - } + // Dirty hack to force the eager load of the configuration + // without Resharper pestering about useless code - // Dirty hack to force the eager load of the configuration - // without Resharper pestering about useless code + if (!Config.HasConfig(ConfigurationLevel.Local)) + { + throw new InvalidOperationException("Unexpected state."); + } + } - if (!Config.HasConfig(ConfigurationLevel.Local)) + if (!string.IsNullOrEmpty(options.IndexPath)) { - throw new InvalidOperationException("Unexpected state."); + // Another dirty hack to avoid warnings + if (Index.Count < 0) + { + throw new InvalidOperationException("Unexpected state."); + } } } @@ -221,7 +231,7 @@ public Index Index throw new BareRepositoryException("Index is not available in a bare repository."); } - return index; + return index.Value; } } @@ -538,13 +548,16 @@ public static string Discover(string startingPath) public static string Clone(string sourceUrl, string workdirPath, CloneOptions options = null) { + Ensure.ArgumentNotNull(sourceUrl, "sourceUrl"); + Ensure.ArgumentNotNull(workdirPath, "workdirPath"); + options = options ?? new CloneOptions(); using (GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(options)) { var gitCheckoutOptions = checkoutOptionsWrapper.Options; - var remoteCallbacks = new RemoteCallbacks(null, options.OnTransferProgress, null, options.CredentialsProvider); + var remoteCallbacks = new RemoteCallbacks(options); var gitRemoteCallbacks = remoteCallbacks.GenerateCallbacks(); var cloneOpts = new GitCloneOptions @@ -555,13 +568,19 @@ public static string Clone(string sourceUrl, string workdirPath, RemoteCallbacks = gitRemoteCallbacks, }; - FilePath repoPath; - using (RepositorySafeHandle repo = Proxy.git_clone(sourceUrl, workdirPath, ref cloneOpts)) + try { - repoPath = Proxy.git_repository_path(repo); - } + cloneOpts.CheckoutBranch = StrictUtf8Marshaler.FromManaged(options.BranchName); - return repoPath.Native; + using (RepositorySafeHandle repo = Proxy.git_clone(sourceUrl, workdirPath, ref cloneOpts)) + { + return Proxy.git_repository_path(repo).Native; + } + } + finally + { + EncodingMarshaler.Cleanup(cloneOpts.CheckoutBranch); + } } } @@ -961,19 +980,6 @@ internal T RegisterForCleanup(T disposable) where T : IDisposable return disposable; } - /// - /// Gets the current LibGit2Sharp version. - /// - /// The format of the version number is as follows: - /// Major.Minor.Patch-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features) - /// - /// - [Obsolete("This property will be removed in the next release. Use GlobalSettings.Version instead.")] - public static string Version - { - get { return GlobalSettings.Version.ToString(); } - } - /// /// Merges changes from commit into the branch pointed at by HEAD. /// @@ -1487,28 +1493,41 @@ public void Stage(IEnumerable paths, StageOptions stageOptions) diffModifiers |= DiffModifiers.IncludeIgnored; } - var changes = Diff.Compare(diffModifiers, paths, explicitPathsOptions); + var changes = Diff.Compare(diffModifiers, paths, explicitPathsOptions, + new CompareOptions { Similarity = SimilarityOptions.None }); - foreach (var treeEntryChanges in changes) + var unexpectedTypesOfChanges = changes + .Where( + tec => tec.Status != ChangeKind.Added && + tec.Status != ChangeKind.Modified && + tec.Status != ChangeKind.Unmodified && + tec.Status != ChangeKind.Deleted).ToList(); + + if (unexpectedTypesOfChanges.Count > 0) { - switch (treeEntryChanges.Status) - { - case ChangeKind.Unmodified: - continue; + throw new InvalidOperationException( + string.Format(CultureInfo.InvariantCulture, + "Entry '{0}' bears an unexpected ChangeKind '{1}'", + unexpectedTypesOfChanges[0].Path, unexpectedTypesOfChanges[0].Status)); + } - case ChangeKind.Deleted: - RemoveFromIndex(treeEntryChanges.Path); - continue; + foreach (TreeEntryChanges treeEntryChanges in changes + .Where(tec => tec.Status == ChangeKind.Deleted)) + { + RemoveFromIndex(treeEntryChanges.Path); + } + foreach (TreeEntryChanges treeEntryChanges in changes) + { + switch (treeEntryChanges.Status) + { case ChangeKind.Added: - /* Fall through */ case ChangeKind.Modified: AddToIndex(treeEntryChanges.Path); - continue; + break; default: - throw new InvalidOperationException( - string.Format(CultureInfo.InvariantCulture, "Entry '{0}' bears an unexpected ChangeKind '{1}'", treeEntryChanges.Path, treeEntryChanges.Status)); + continue; } } @@ -1872,6 +1891,30 @@ private IEnumerable RemoveStagedItems(IEnumerable paths, bool re return removed; } + /// + /// Finds the most recent annotated tag that is reachable from a commit. + /// + /// If the tag points to the commit, then only the tag is shown. Otherwise, + /// it suffixes the tag name with the number of additional commits on top + /// of the tagged object and the abbreviated object name of the most recent commit. + /// + /// + /// Optionally, the parameter allow to tweak the + /// search strategy (considering lightweith tags, or even branches as reference points) + /// and the formatting of the returned identifier. + /// + /// + /// The commit to be described. + /// Determines how the commit will be described. + /// A descriptive identifier for the commit based on the nearest annotated tag. + public string Describe(Commit commit, DescribeOptions options) + { + Ensure.ArgumentNotNull(commit, "commit"); + Ensure.ArgumentNotNull(options, "options"); + + return Proxy.git_describe_commit(handle, commit.Id, options); + } + private string DebuggerDisplay { get diff --git a/LibGit2Sharp/RepositoryExtensions.cs b/LibGit2Sharp/RepositoryExtensions.cs index a86064a45..3423f418f 100644 --- a/LibGit2Sharp/RepositoryExtensions.cs +++ b/LibGit2Sharp/RepositoryExtensions.cs @@ -738,5 +738,21 @@ public static RepositoryStatus RetrieveStatus(this IRepository repository) Proxy.git_index_read(repository.Index.Handle); return new RepositoryStatus((Repository)repository, null); } + + /// + /// Finds the most recent annotated tag that is reachable from a commit. + /// + /// If the tag points to the commit, then only the tag is shown. Otherwise, + /// it suffixes the tag name with the number of additional commits on top + /// of the tagged object and the abbreviated object name of the most recent commit. + /// + /// + /// The being worked with. + /// The commit to be described. + /// A descriptive identifier for the commit based on the nearest annotated tag. + public static string Describe(this IRepository repository, Commit commit) + { + return repository.Describe(commit, new DescribeOptions()); + } } } diff --git a/LibGit2Sharp/RepositoryStatus.cs b/LibGit2Sharp/RepositoryStatus.cs index 235f514d7..1eac10e16 100644 --- a/LibGit2Sharp/RepositoryStatus.cs +++ b/LibGit2Sharp/RepositoryStatus.cs @@ -123,6 +123,17 @@ private static GitStatusOptions CreateStatusOptions(StatusOptions options) GitStatusOptionFlags.RecurseIgnoredDirs; } + if (options.PathSpec != null) + { + coreOptions.PathSpec = GitStrArrayManaged.BuildFrom(options.PathSpec); + } + + if (options.DisablePathSpecMatch) + { + coreOptions.Flags |= + GitStatusOptionFlags.DisablePathspecMatch; + } + return coreOptions; } diff --git a/LibGit2Sharp/StatusOptions.cs b/LibGit2Sharp/StatusOptions.cs index 9c7528017..5516bbf0d 100644 --- a/LibGit2Sharp/StatusOptions.cs +++ b/LibGit2Sharp/StatusOptions.cs @@ -66,5 +66,20 @@ public StatusOptions() /// Recurse into ignored directories /// public bool RecurseIgnoredDirs { get; set; } + + /// + /// Limit the scope of paths to consider to the provided pathspecs + /// + /// + /// If a PathSpec is given, the results from rename detection may + /// not be accurate. + /// + public string[] PathSpec { get; set; } + + /// + /// When set to true, the PathSpec paths will be considered + /// as explicit paths, and NOT as pathspecs containing globs. + /// + public bool DisablePathSpecMatch { get; set; } } } diff --git a/LibGit2Sharp/Submodule.cs b/LibGit2Sharp/Submodule.cs index c15e224d0..81f677547 100644 --- a/LibGit2Sharp/Submodule.cs +++ b/LibGit2Sharp/Submodule.cs @@ -21,7 +21,7 @@ public class Submodule : IEquatable, IBelongToARepository private readonly ILazy headCommitId; private readonly ILazy indexCommitId; private readonly ILazy workdirCommitId; - private readonly ILazy fetchRecurseSubmodulesRule; + private readonly ILazy fetchRecurseSubmodulesRule; private readonly ILazy ignoreRule; private readonly ILazy updateRule; @@ -46,7 +46,7 @@ internal Submodule(Repository repo, string name, string path, string url) var rules = new SubmoduleLazyGroup(repo, name); fetchRecurseSubmodulesRule = rules.AddLazy(Proxy.git_submodule_fetch_recurse_submodules); ignoreRule = rules.AddLazy(Proxy.git_submodule_ignore); - updateRule = rules.AddLazy(Proxy.git_submodule_update); + updateRule = rules.AddLazy(Proxy.git_submodule_update_strategy); } /// @@ -85,7 +85,7 @@ internal Submodule(Repository repo, string name, string path, string url) /// Note that at this time, LibGit2Sharp does not honor this setting and the /// fetch functionality current ignores submodules. /// - public virtual bool FetchRecurseSubmodulesRule { get { return fetchRecurseSubmodulesRule.Value; } } + public virtual SubmoduleRecurse FetchRecurseSubmodulesRule { get { return fetchRecurseSubmodulesRule.Value; } } /// /// The ignore rule of the submodule. diff --git a/LibGit2Sharp/SubmoduleCollection.cs b/LibGit2Sharp/SubmoduleCollection.cs index 8713e3e4c..7e76036f5 100644 --- a/LibGit2Sharp/SubmoduleCollection.cs +++ b/LibGit2Sharp/SubmoduleCollection.cs @@ -48,6 +48,74 @@ public virtual Submodule this[string name] } } + /// + /// Initialize specified submodule. + /// + /// Existing entries in the config file for this submodule are not be + /// modified unless is true. + /// + /// + /// The name of the submodule to update. + /// Overwrite existing entries. + public virtual void Init(string name, bool overwrite) + { + using (var handle = Proxy.git_submodule_lookup(repo.Handle, name)) + { + if (handle == null) + { + throw new NotFoundException(string.Format( + CultureInfo.InvariantCulture, + "Submodule lookup failed for '{0}'.", name)); + } + + Proxy.git_submodule_init(handle, overwrite); + } + } + + /// + /// Update specified submodule. + /// + /// This will: + /// 1) Optionally initialize the if it not already initialzed, + /// 2) clone the sub repository if it has not already been cloned, and + /// 3) checkout the commit ID for the submodule in the sub repository. + /// + /// + /// The name of the submodule to update. + /// Options controlling submodule udpate behavior and callbacks. + public virtual void Update(string name, SubmoduleUpdateOptions options) + { + options = options ?? new SubmoduleUpdateOptions(); + + using (var handle = Proxy.git_submodule_lookup(repo.Handle, name)) + { + if (handle == null) + { + throw new NotFoundException(string.Format( + CultureInfo.InvariantCulture, + "Submodule lookup failed for '{0}'.", name)); + } + + using (GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(options)) + { + var gitCheckoutOptions = checkoutOptionsWrapper.Options; + + var remoteCallbacks = new RemoteCallbacks(options); + var gitRemoteCallbacks = remoteCallbacks.GenerateCallbacks(); + + var gitSubmoduleUpdateOpts = new GitSubmoduleOptions + { + Version = 1, + CheckoutOptions = gitCheckoutOptions, + RemoteCallbacks = gitRemoteCallbacks, + CloneCheckoutStrategy = CheckoutStrategy.GIT_CHECKOUT_SAFE_CREATE + }; + + Proxy.git_submodule_update(handle, options.Init, ref gitSubmoduleUpdateOpts); + } + } + } + /// /// Returns an enumerator that iterates through the collection. /// diff --git a/LibGit2Sharp/SubmoduleRecurse.cs b/LibGit2Sharp/SubmoduleRecurse.cs new file mode 100644 index 000000000..7ad024c0d --- /dev/null +++ b/LibGit2Sharp/SubmoduleRecurse.cs @@ -0,0 +1,25 @@ +namespace LibGit2Sharp +{ + /// + /// Submodule recurse rule options. + /// + public enum SubmoduleRecurse + { + /// + /// Reset to the value in the config. + /// + Reset = -1, + /// + /// Do not recurse into submodules. + /// + No = 0, + /// + /// Recurse into submodules. + /// + Yes = 1, + /// + /// Recurse into submodules only when commit not already in local clone. + /// + OnDemand = 2, + } +} diff --git a/LibGit2Sharp/SubmoduleUpdate.cs b/LibGit2Sharp/SubmoduleUpdate.cs index 02f290bc8..45fad71d8 100644 --- a/LibGit2Sharp/SubmoduleUpdate.cs +++ b/LibGit2Sharp/SubmoduleUpdate.cs @@ -8,22 +8,27 @@ public enum SubmoduleUpdate /// /// Reset to the last saved update rule. /// - Default = -1, + Reset = -1, /// - /// Checkout the commit recorded in the superproject. + /// Only used when you don't want to specify any particular update + /// rule. /// - Checkout = 0, + Unspecified = 0, + /// + /// This is the default - checkout the commit recorded in the superproject. + /// + Checkout = 1, /// /// Rebase the current branch of the submodule onto the commit recorded in the superproject. /// - Rebase = 1, + Rebase = 2, /// /// Merge the commit recorded in the superproject into the current branch of the submodule. /// - Merge = 2, + Merge = 3, /// /// Do not update the submodule. /// - None = 3, + None = 4, } } diff --git a/LibGit2Sharp/SubmoduleUpdateOptions.cs b/LibGit2Sharp/SubmoduleUpdateOptions.cs new file mode 100644 index 000000000..89f895d75 --- /dev/null +++ b/LibGit2Sharp/SubmoduleUpdateOptions.cs @@ -0,0 +1,48 @@ +using LibGit2Sharp.Core; +using LibGit2Sharp.Handlers; + +namespace LibGit2Sharp +{ + /// + /// Options controlling Submodule Update behavior and callbacks. + /// + public sealed class SubmoduleUpdateOptions : FetchOptionsBase, IConvertableToGitCheckoutOpts + { + /// + /// Initialize the submodule if it is not already initialized. + /// + public bool Init { get; set; } + + /// + /// Delegate to be called during checkout for files that match + /// desired filter specified with the NotifyFlags property. + /// + public CheckoutNotifyHandler OnCheckoutNotify { get; set; } + + /// Delegate through which checkout will notify callers of + /// certain conditions. The conditions that are reported is + /// controlled with the CheckoutNotifyFlags property. + public CheckoutProgressHandler OnCheckoutProgress { get; set; } + + /// + /// The flags specifying what conditions are + /// reported through the OnCheckoutNotify delegate. + /// + public CheckoutNotifyFlags CheckoutNotifyFlags { get; set; } + + CheckoutCallbacks IConvertableToGitCheckoutOpts.GenerateCallbacks() + { + return CheckoutCallbacks.From(OnCheckoutProgress, OnCheckoutNotify); + } + + CheckoutStrategy IConvertableToGitCheckoutOpts.CheckoutStrategy + { + get { return CheckoutStrategy.GIT_CHECKOUT_SAFE; } + } + + CheckoutNotifyFlags IConvertableToGitCheckoutOpts.CheckoutNotifyFlags + { + get { return CheckoutNotifyFlags; } + } + } +} diff --git a/LibGit2Sharp/TransferProgress.cs b/LibGit2Sharp/TransferProgress.cs index 4ef072a8a..29638103a 100644 --- a/LibGit2Sharp/TransferProgress.cs +++ b/LibGit2Sharp/TransferProgress.cs @@ -1,10 +1,13 @@ -using LibGit2Sharp.Core; +using System.Diagnostics; +using System.Globalization; +using LibGit2Sharp.Core; namespace LibGit2Sharp { /// /// Expose progress values from a fetch operation. /// + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class TransferProgress { private GitTransferProgress gitTransferProgress; @@ -66,5 +69,14 @@ public virtual long ReceivedBytes return (long) gitTransferProgress.received_bytes; } } + + private string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, + "{0}/{1}, {2} bytes", ReceivedObjects, TotalObjects, ReceivedBytes); + } + } } } diff --git a/LibGit2Sharp/TreeDefinition.cs b/LibGit2Sharp/TreeDefinition.cs index bedd07851..62efd4fb9 100644 --- a/LibGit2Sharp/TreeDefinition.cs +++ b/LibGit2Sharp/TreeDefinition.cs @@ -283,7 +283,7 @@ internal Tree Build(Repository repository) { WrapAllTreeDefinitions(repository); - using (var builder = new TreeBuilder()) + using (var builder = new TreeBuilder(repository)) { var builtTreeEntryDefinitions = new List>(entries.Count); @@ -309,7 +309,7 @@ internal Tree Build(Repository repository) builtTreeEntryDefinitions.ForEach(t => entries[t.Item1] = t.Item2); - ObjectId treeId = builder.Write(repository); + ObjectId treeId = builder.Write(); return repository.Lookup(treeId); } } @@ -371,9 +371,9 @@ private class TreeBuilder : IDisposable { private readonly TreeBuilderSafeHandle handle; - public TreeBuilder() + public TreeBuilder(Repository repo) { - handle = Proxy.git_treebuilder_create(); + handle = Proxy.git_treebuilder_new(repo.Handle); } public void Insert(string name, TreeEntryDefinition treeEntryDefinition) @@ -381,9 +381,9 @@ public void Insert(string name, TreeEntryDefinition treeEntryDefinition) Proxy.git_treebuilder_insert(handle, name, treeEntryDefinition); } - public ObjectId Write(Repository repo) + public ObjectId Write() { - return Proxy.git_treebuilder_write(repo.Handle, handle); + return Proxy.git_treebuilder_write(handle); } public void Dispose() diff --git a/LibGit2Sharp/Version.cs b/LibGit2Sharp/Version.cs index f519c3a17..b31bd3c70 100644 --- a/LibGit2Sharp/Version.cs +++ b/LibGit2Sharp/Version.cs @@ -1,5 +1,7 @@ -using System.Globalization; +using System; +using System.Globalization; using System.IO; +using System.Linq; using System.Reflection; using LibGit2Sharp.Core; @@ -24,9 +26,10 @@ internal static Version Build() } /// - /// Returns the of the + /// Returns the of the /// the LibGit2Sharp library. /// + [Obsolete("This property will be removed in the next release. Please use InformationalVersion instead.")] public virtual System.Version MajorMinorPatch { get @@ -35,6 +38,21 @@ public virtual System.Version MajorMinorPatch } } + /// + /// Returns version of the LibGit2Sharp library. + /// + public virtual string InformationalVersion + { + get + { + var attribute = (AssemblyInformationalVersionAttribute)assembly + .GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false) + .Single(); + + return attribute.InformationalVersion; + } + } + /// /// Returns all the optional features that were compiled into /// libgit2. @@ -49,7 +67,7 @@ public virtual BuiltInFeatures Features } /// - /// Returns the SHA hash for the libgit2 library. + /// Returns the SHA hash for the libgit2 library. /// public virtual string LibGit2CommitSha { @@ -90,7 +108,7 @@ private string RetrieveVersion() return string.Format( CultureInfo.InvariantCulture, "{0}-{1}-{2} ({3} - {4})", - MajorMinorPatch.ToString(3), + InformationalVersion, LibGit2SharpCommitSha, LibGit2CommitSha, NativeMethods.ProcessorArchitecture, diff --git a/LibGit2Sharp/libgit2_hash.txt b/LibGit2Sharp/libgit2_hash.txt index 880e8c011..4a8fde8aa 100644 --- a/LibGit2Sharp/libgit2_hash.txt +++ b/LibGit2Sharp/libgit2_hash.txt @@ -1 +1 @@ -4a30c53146e7d1068af6f02dba3ef925878d11b8 +e0902fbce7d14631bd02091c1c70cde3e68f78ab diff --git a/README.md b/README.md index 18379c00c..018fbdc97 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # LibGit2Sharp -**LibGit2Sharp brings all the might and speed of [libgit2][0], a native Git implementation, to the managed world of .Net and Mono.** +**LibGit2Sharp brings all the might and speed of [libgit2][libgit2], a native Git implementation, to the managed world of .Net and Mono.** - [0]: http://libgit2.github.com/ + [libgit2]: http://libgit2.github.com/ ## Prerequisites @@ -11,43 +11,41 @@ ## Online resources - - [NuGet package][1] (Requires NuGet 2.7+) - - [Source code][2] - - [Continuous integration][3] + - [NuGet package][nuget] (Requires NuGet 2.7+) + - [Source code][source] - [1]: http://nuget.org/List/Packages/LibGit2Sharp - [2]: https://github.com/libgit2/libgit2sharp/ - [3]: http://teamcity.codebetter.com/project.html?projectId=project127&guest=1 + [nuget]: http://nuget.org/List/Packages/LibGit2Sharp + [source]: https://github.com/libgit2/libgit2sharp/ ## Troubleshooting and support - - Usage or programming related question? Post it on [StackOverflow][4] using the tag *libgit2sharp* - - Found a bug or missing a feature? Feed the [issue tracker][5] - - Announcements and related miscellanea through Twitter ([@libgit2sharp][6]) + - Usage or programming related question? Post it on [StackOverflow][so] using the tag *libgit2sharp* + - Found a bug or missing a feature? Feed the [issue tracker][tracker] + - Announcements and related miscellanea through Twitter ([@libgit2sharp][twitter]) - [4]: http://stackoverflow.com/questions/tagged/libgit2sharp - [5]: https://github.com/libgit2/libgit2sharp/issues - [6]: http://twitter.com/libgit2sharp + [so]: http://stackoverflow.com/questions/tagged/libgit2sharp + [tracker]: https://github.com/libgit2/libgit2sharp/issues + [twitter]: http://twitter.com/libgit2sharp ## Current project build status -The [build][3] is generously hosted and run on the [CodeBetter TeamCity][7] infrastructure. - -| | Status of last build | -| :------ | :------: | -| **master** | [![master][8]][9] | -| **vNext (Win x86)** | [![vNext x86][10]][11] | -| **vNext (Win amd64)** | [![vNext amd64][12]][13] | -| **vNext (Mono)** | [![vNext Mono][14]][15] | - - [7]: http://codebetter.com/codebetter-ci/ - [8]: http://teamcity.codebetter.com/app/rest/builds/buildType:(id:bt398)/statusIcon - [9]: http://teamcity.codebetter.com/viewType.html?buildTypeId=bt398&guest=1 - [10]: http://teamcity.codebetter.com/app/rest/builds/buildType:(id:bt651)/statusIcon - [11]: http://teamcity.codebetter.com/viewType.html?buildTypeId=bt651&guest=1 - [12]: http://teamcity.codebetter.com/app/rest/builds/buildType:(id:bt652)/statusIcon - [13]: http://teamcity.codebetter.com/viewType.html?buildTypeId=bt652&guest=1 - [14]: http://teamcity.codebetter.com/app/rest/builds/buildType:(id:bt656)/statusIcon - [15]: http://teamcity.codebetter.com/viewType.html?buildTypeId=bt656&guest=1 +The CI builds are generously hosted and run on the [Travis][travis] and [AppVeyor][appveyor] infrastructures. + +| | Windows (x86/amd64) | Linux/MacOsX | +| :------ | :------: | :------: | +| **master** | [![master win][master-win-badge]][master-win] | [![master nix][master-nix-badge]][master-nix] | +| **vNext** | [![vNext win][vNext-win-badge]][vNext-win] | [![vNext nix][vNext-nix-badge]][vNext-nix] | + + + [travis]: http://travis-ci.org/ + [appveyor]: http://appveyor.com/ + [master-win-badge]: https://ci.appveyor.com/api/projects/status/8qxcoqdo9kp7x2w9/branch/master?svg=true + [master-win]: https://ci.appveyor.com/project/libgit2/libgit2sharp/branch/master + [master-nix-badge]: https://travis-ci.org/libgit2/libgit2sharp.svg?branch=master + [master-nix]: https://travis-ci.org/libgit2/libgit2sharp/branches + [vNext-win-badge]: https://ci.appveyor.com/api/projects/status/8qxcoqdo9kp7x2w9/branch/vNext?svg=true + [vNext-win]: https://ci.appveyor.com/project/libgit2/libgit2sharp/branch/vNext + [vNext-nix-badge]: https://travis-ci.org/libgit2/libgit2sharp.svg?branch=vNext + [vNext-nix]: https://travis-ci.org/libgit2/libgit2sharp/branches ## Quick contributing guide @@ -55,20 +53,20 @@ The [build][3] is generously hosted and run on the [CodeBetter TeamCity][7] infr - Create a topic specific branch. Add some nice feature. Do not forget the tests ;-) - Send a Pull Request to spread the fun! -More thorough information available in the [wiki][16]. +More thorough information available in the [wiki][wiki]. - [16]: https://github.com/libgit2/libgit2sharp/wiki + [wiki]: https://github.com/libgit2/libgit2sharp/wiki ## Authors - - **Code:** The LibGit2Sharp [contributors][17] - - **Logo:** [Jason "blackant" Long][18] + - **Code:** The LibGit2Sharp [contributors][committers] + - **Logo:** [Jason "blackant" Long][blackant] - [17]: https://github.com/libgit2/libgit2sharp/contributors - [18]: https://github.com/jasonlong + [committers]: https://github.com/libgit2/libgit2sharp/contributors + [blackant]: https://github.com/jasonlong ## License -The MIT license (Refer to the [LICENSE.md][19] file) +The MIT license (Refer to the [LICENSE.md][license] file) - [19]: https://github.com/libgit2/libgit2sharp/blob/master/LICENSE.md + [license]: https://github.com/libgit2/libgit2sharp/blob/master/LICENSE.md diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..1497c4381 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,75 @@ +version: '0.21.0.{build}' + +branches: + only: + - master + - vNext + +skip_tags: true + +clone_folder: C:\projects\libgit2sharp + +environment: + matrix: + - xunit_runner: xunit.console.clr4.exe + Arch: 64 + - xunit_runner: xunit.console.clr4.x86.exe + Arch: 32 + +matrix: + fast_finish: true + +install: +- ps: | + Write-Host "Commit being built = $($Env:APPVEYOR_REPO_COMMIT)" + Write-Host "Current build version = $($Env:APPVEYOR_BUILD_VERSION)" + Write-Host "Target branch = $($Env:APPVEYOR_REPO_BRANCH)" + Write-Host "Is a Pull Request = $($Env:APPVEYOR_PULL_REQUEST_NUMBER -ne $null)" + $VersionSuffix = "" + If ($Env:APPVEYOR_REPO_BRANCH -ne "master") + { + $VersionSuffix = "-pre" + } + $Version = "$($Env:APPVEYOR_BUILD_VERSION)$($VersionSuffix)" + $Env:ASSEMBLY_INFORMATIONAL_VERSION = $Version + Write-Host "Assembly informational version = $($Env:ASSEMBLY_INFORMATIONAL_VERSION)" + $ShouldPublishNugetArtifact = "$($env:APPVEYOR_PULL_REQUEST_NUMBER -eq $null)" + $Env:SHOULD_PUBLISH_NUGET_ARTIFACT = $ShouldPublishNugetArtifact + Write-Host "Should publish Nuget artifact = $($Env:SHOULD_PUBLISH_NUGET_ARTIFACT)" + +assembly_info: + patch: true + file: LibGit2Sharp\Properties\AssemblyInfo.cs + assembly_version: '{version}' + assembly_file_version: '{version}' + assembly_informational_version: '$(ASSEMBLY_INFORMATIONAL_VERSION)' + +cache: + - packages + +before_build: +- nuget restore "C:\projects\libgit2sharp\LibGit2Sharp.sln" + +build_script: +- msbuild "C:\projects\libgit2sharp\LibGit2Sharp.sln" /verbosity:normal /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /property:ExtraDefine="LEAKS_IDENTIFYING" + +test_script: +- '%xunit_runner% "C:\projects\libgit2sharp\LibGit2Sharp.Tests\bin\Release\LibGit2Sharp.Tests.dll" /appveyor' +- IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% + +on_success: +- ps: | +- ps: | + & "C:\projects\libgit2sharp\nuget.package\BuildNugetPackage.ps1" "$env:APPVEYOR_REPO_COMMIT" + Add-Type -Path "C:\projects\libgit2sharp\LibGit2Sharp\bin\Release\LibGit2Sharp.dll" + Write-Host "LibGit2Sharp version = $([LibGit2Sharp.GlobalSettings]::Version)" -ForegroundColor "Magenta" + If ($Env:SHOULD_PUBLISH_NUGET_ARTIFACT -eq $True) + { + Get-ChildItem "C:\projects\libgit2sharp\LibGit2sharp\*.nupkg" | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } + } + +notifications: +- provider: Email + to: + - emeric.fermas@gmail.com + on_build_status_changed: true diff --git a/build.libgit2sharp.cmd b/build.libgit2sharp.cmd index 54ecc1a26..6cd7d72cf 100644 --- a/build.libgit2sharp.cmd +++ b/build.libgit2sharp.cmd @@ -1,12 +1,35 @@ +@ECHO OFF + +REM Sample usages: +REM +REM Building and running tests +REM - build.libgit2sharp.cmd +REM +REM Building, running tests and embedding the libgit2sharp commit sha +REM - build.libgit2sharp.cmd "6a6eb81272876fd63555165beef44de2aaa78a14" +REM +REM Building and identifying potential leaks while running tests +REM - build.libgit2sharp.cmd "unknown" "LEAKS_IDENTIFYING" + + SETLOCAL SET BASEDIR=%~dp0 SET FrameworkVersion=v4.0.30319 SET FrameworkDir=%SystemRoot%\Microsoft.NET\Framework + +if exist "%SystemRoot%\Microsoft.NET\Framework64" ( + SET FrameworkDir=%SystemRoot%\Microsoft.NET\Framework64 +) + +ECHO ON + SET CommitSha=%~1 +SET ExtraDefine=%~2 -"%FrameworkDir%\%FrameworkVersion%\msbuild.exe" "%BASEDIR%CI\build.msbuild" /property:CommitSha=%CommitSha% +"%BASEDIR%Lib/NuGet/NuGet.exe" restore "%BASEDIR%LibGit2Sharp.sln" +"%FrameworkDir%\%FrameworkVersion%\msbuild.exe" "%BASEDIR%CI\build.msbuild" /property:CommitSha=%CommitSha% /property:ExtraDefine="%ExtraDefine%" ENDLOCAL -EXIT /B %ERRORLEVEL% \ No newline at end of file +EXIT /B %ERRORLEVEL% diff --git a/build.libgit2sharp.sh b/build.libgit2sharp.sh index a64434fb2..d650afd26 100755 --- a/build.libgit2sharp.sh +++ b/build.libgit2sharp.sh @@ -2,6 +2,7 @@ LIBGIT2SHA=`cat ./LibGit2Sharp/libgit2_hash.txt` SHORTSHA=${LIBGIT2SHA:0:7} +EXTRADEFINE="$1" rm -rf libgit2/build mkdir libgit2/build @@ -26,6 +27,11 @@ export MONO_OPTIONS=--debug echo $DYLD_LIBRARY_PATH echo $LD_LIBRARY_PATH -xbuild CI/build.msbuild /t:Deploy + +# Required for NuGet package restore to run. +mozroots --import --sync + +mono Lib/NuGet/NuGet.exe restore LibGit2Sharp.sln +xbuild CI/build.msbuild /target:Deploy /property:ExtraDefine="$EXTRADEFINE" exit $? diff --git a/build.libgit2sharp.x64.cmd b/build.libgit2sharp.x64.cmd deleted file mode 100644 index 41702104b..000000000 --- a/build.libgit2sharp.x64.cmd +++ /dev/null @@ -1,12 +0,0 @@ -SETLOCAL - -SET BASEDIR=%~dp0 -SET FrameworkVersion=v4.0.30319 -SET FrameworkDir=%SystemRoot%\Microsoft.NET\Framework64 -SET CommitSha=%~1 - -"%FrameworkDir%\%FrameworkVersion%\msbuild.exe" "%BASEDIR%CI\build.msbuild" /property:CommitSha=%CommitSha% - -ENDLOCAL - -EXIT /B %ERRORLEVEL% \ No newline at end of file diff --git a/libgit2 b/libgit2 index 4a30c5314..e0902fbce 160000 --- a/libgit2 +++ b/libgit2 @@ -1 +1 @@ -Subproject commit 4a30c53146e7d1068af6f02dba3ef925878d11b8 +Subproject commit e0902fbce7d14631bd02091c1c70cde3e68f78ab diff --git a/nuget.package/BuildNugetPackage.ps1 b/nuget.package/BuildNugetPackage.ps1 new file mode 100644 index 000000000..5dac796e0 --- /dev/null +++ b/nuget.package/BuildNugetPackage.ps1 @@ -0,0 +1,81 @@ +<# +.SYNOPSIS + Generates the NuGet packages (including the symbols). + A clean build is performed the packaging. +.PARAMETER commitSha + The LibGit2Sharp commit sha that contains the version of the source code being packaged. +#> + +Param( + [Parameter(Mandatory=$true)] + [string]$commitSha +) + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version Latest + +function Run-Command([scriptblock]$Command) { + $output = "" + + $exitCode = 0 + $global:lastexitcode = 0 + + & $Command + + if ($LastExitCode -ne 0) { + $exitCode = $LastExitCode + } elseif (!$?) { + $exitCode = 1 + } else { + return + } + + $error = "``$Command`` failed" + + if ($output) { + Write-Host -ForegroundColor "Red" $output + $error += ". See output above." + } + + Throw $error +} + +function Clean-OutputFolder($folder) { + + If (Test-Path $folder) { + Write-Host -ForegroundColor "Green" "Dropping `"$folder`" folder..." + + Run-Command { & Remove-Item -Recurse -Force "$folder" } + + Write-Host "Done." + } +} + +################# + +$root = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition +$projectPath = Join-Path $root "..\LibGit2Sharp" + +Remove-Item (Join-Path $projectPath "*.nupkg") + +Clean-OutputFolder (Join-Path $projectPath "bin\") +Clean-OutputFolder (Join-Path $projectPath "obj\") + +# The nuspec file needs to be next to the csproj, so copy it there during the pack operation +Copy-Item (Join-Path $root "LibGit2Sharp.nuspec") $projectPath + +Push-Location $projectPath + +try { + Set-Content -Encoding ASCII $(Join-Path $projectPath "libgit2sharp_hash.txt") $commitSha + Run-Command { & "$(Join-Path $projectPath "..\Lib\NuGet\Nuget.exe")" Restore "$(Join-Path $projectPath "..\LibGit2Sharp.sln")" } + + # Cf. https://stackoverflow.com/questions/21728450/nuget-exclude-files-from-symbols-package-in-nuspec + Run-Command { & "$(Join-Path $projectPath "..\Lib\NuGet\Nuget.exe")" Pack -Build -Symbols "$(Join-Path $projectPath "LibGit2Sharp.csproj")" -Prop Configuration=Release -Exclude "**/NativeBinaries/**/*.*"} + Run-Command { & "$(Join-Path $projectPath "..\Lib\NuGet\Nuget.exe")" Pack "$(Join-Path $projectPath "LibGit2Sharp.csproj")" -Prop Configuration=Release } +} +finally { + Pop-Location + Remove-Item (Join-Path $projectPath "LibGit2Sharp.nuspec") + Set-Content -Encoding ASCII $(Join-Path $projectPath "libgit2sharp_hash.txt") "unknown" +} diff --git a/nuget.package/build.nuget.package.cmd b/nuget.package/build.nuget.package.cmd deleted file mode 100644 index 6def1d6d7..000000000 --- a/nuget.package/build.nuget.package.cmd +++ /dev/null @@ -1,31 +0,0 @@ -SETLOCAL -SET BASEDIR=%~dp0 -SET SRCDIR=%BASEDIR%..\LibGit2Sharp\ -SET CommitSha=%~1 - -IF "%CommitSha%" == "" ( - ECHO "Please provide the Libgit2Sharp commit Sha this package is being built from." - EXIT /B 1 -) - -REM the nuspec file needs to be next to the csproj, so copy it there during the pack operation -COPY "%BASEDIR%LibGit2Sharp.nuspec" "%SRCDIR%" - -PUSHD "%BASEDIR%" - -DEL *.nupkg - -CMD /c "..\build.libgit2sharp.cmd %CommitSha%" - -IF %ERRORLEVEL% NEQ 0 GOTO EXIT - -"..\Lib\NuGet\NuGet.exe" Pack -Symbols "%SRCDIR%LibGit2Sharp.csproj" -Prop Configuration=Release - -:EXIT -DEL "%SRCDIR%LibGit2Sharp.nuspec" - -ENDLOCAL -POPD - -PAUSE -EXIT /B %ERRORLEVEL% diff --git a/nuget.package/build/LibGit2Sharp.props b/nuget.package/build/LibGit2Sharp.props index 8e216f90c..8ffc28d6e 100644 --- a/nuget.package/build/LibGit2Sharp.props +++ b/nuget.package/build/LibGit2Sharp.props @@ -1,20 +1,20 @@  - - NativeBinaries\amd64\git2-4a30c53.dll + + NativeBinaries\amd64\git2-e0902fb.dll PreserveNewest - - NativeBinaries\amd64\git2-4a30c53.pdb + + NativeBinaries\amd64\git2-e0902fb.pdb PreserveNewest - - NativeBinaries\x86\git2-4a30c53.dll + + NativeBinaries\x86\git2-e0902fb.dll PreserveNewest - - NativeBinaries\x86\git2-4a30c53.pdb + + NativeBinaries\x86\git2-e0902fb.pdb PreserveNewest