public void TestTooLongGitSHA1IsNotCommitReference() { var packageRef = new PackageRef { GitRef = "096932a9ea478c049802f5e2eb6538e37336234cd", }; _assert.False(packageRef.IsStaticReference); }
public void GenerationIsCorrect() { this.SetupTest("PackageLocationParentAndTwoSubmoduleSamePackage"); var src = this.SetupSrcPackage(); try { // Make sure the Package directory is removed so we have a clean test every time. if (Directory.Exists(this.GetPath("Package"))) { PathUtils.AggressiveDirectoryDelete(this.GetPath("Package")); } if (Directory.Exists(this.GetPath("SubmoduleA\\Package"))) { PathUtils.AggressiveDirectoryDelete(this.GetPath("SubmoduleA\\Package")); } if (Directory.Exists(this.GetPath("SubmoduleB\\Package"))) { PathUtils.AggressiveDirectoryDelete(this.GetPath("SubmoduleB\\Package")); } this.Generate(args: "--redirect http://protobuild.org/hach-que/TestEmptyPackage local-git://" + src); _assert.True(File.Exists(this.GetPath("Package\\PackageLibrary\\PackageLibrary.Windows.csproj"))); _assert.False( File.Exists(this.GetPath("SubmoduleA\\Package\\PackageLibrary\\PackageLibrary.Windows.csproj"))); _assert.False( File.Exists(this.GetPath("SubmoduleB\\Package\\PackageLibrary\\PackageLibrary.Windows.csproj"))); _assert.True(File.Exists(this.GetPath("SubmoduleA\\Package\\.redirect"))); _assert.True(File.Exists(this.GetPath("SubmoduleB\\Package\\.redirect"))); _assert.True(File.Exists(this.GetPath("SubmoduleA\\LibraryA\\LibraryA.Windows.csproj"))); _assert.True(File.Exists(this.GetPath("SubmoduleB\\LibraryB\\LibraryB.Windows.csproj"))); var consoleContents = this.ReadFile("Console\\Console.Windows.csproj"); var libraryAContents = this.ReadFile("SubmoduleA\\LibraryA\\LibraryA.Windows.csproj"); var libraryBContents = this.ReadFile("SubmoduleB\\LibraryB\\LibraryB.Windows.csproj"); _assert.Contains( @"Include=""..\Package\PackageLibrary\PackageLibrary.Windows.csproj""", consoleContents); _assert.Contains( @"Include=""..\..\Package\PackageLibrary\PackageLibrary.Windows.csproj""", libraryAContents); _assert.Contains( @"Include=""..\..\Package\PackageLibrary\PackageLibrary.Windows.csproj""", libraryBContents); } finally { PathUtils.AggressiveDirectoryDelete(src); } }
public void IsNotOnGroundWhenNoEntities() { var kernel = new StandardKernel(); kernel.Load <ProtogameCoreModule>(); kernel.Load <ProtogamePlatformingIoCModule>(); var platforming = kernel.Get <IPlatforming>(); _assert.False(platforming.IsOnGround( this.CreateBoundingBox(200, 200, 16, 16), new IBoundingBox[0], x => true)); }
public void GenerationIsCorrect() { this.SetupTest("ServicesDisable"); this.Generate(); _assert.True(File.Exists(this.GetPath(@"Console\Console.Windows.csproj"))); _assert.True(File.Exists(this.GetPath(@"Submodule\Library\Library.Windows.csproj"))); _assert.True(File.Exists(this.GetPath(@"Submodule\Library\LibraryExcludable.Windows.csproj"))); var consoleContents = this.ReadFile(@"Console\Console.Windows.csproj"); var libraryContents = this.ReadFile(@"Submodule\Library\Library.Windows.csproj"); var libraryExcludableContents = this.ReadFile(@"Submodule\Library\LibraryExcludable.Windows.csproj"); _assert.Contains("CONSOLE_SERVICE_A;", consoleContents); _assert.Contains("LIBRARY_SERVICE_B;", libraryContents); _assert.Contains("LIBRARY_SERVICE_C;", libraryContents); _assert.Contains("LIBRARY_SERVICE_D;", libraryExcludableContents); this.Generate(args: "--disable Console/ServiceA"); _assert.True(File.Exists(this.GetPath(@"Console\Console.Windows.csproj"))); _assert.True(File.Exists(this.GetPath(@"Submodule\Library\Library.Windows.csproj"))); _assert.False(File.Exists(this.GetPath(@"Submodule\Library\LibraryExcludable.Windows.csproj"))); consoleContents = this.ReadFile(@"Console\Console.Windows.csproj"); libraryContents = this.ReadFile(@"Submodule\Library\Library.Windows.csproj"); _assert.DoesNotContain("CONSOLE_SERVICE_A;", consoleContents); _assert.DoesNotContain("LIBRARY_SERVICE_B;", libraryContents); _assert.Contains("LIBRARY_SERVICE_C;", libraryContents); this.Generate(args: "--disable Library/ServiceB"); _assert.True(File.Exists(this.GetPath(@"Console\Console.Windows.csproj"))); _assert.True(File.Exists(this.GetPath(@"Submodule\Library\Library.Windows.csproj"))); _assert.False(File.Exists(this.GetPath(@"Submodule\Library\LibraryExcludable.Windows.csproj"))); consoleContents = this.ReadFile(@"Console\Console.Windows.csproj"); libraryContents = this.ReadFile(@"Submodule\Library\Library.Windows.csproj"); _assert.DoesNotContain("CONSOLE_SERVICE_A;", consoleContents); _assert.DoesNotContain("LIBRARY_SERVICE_B;", libraryContents); _assert.Contains("LIBRARY_SERVICE_C;", libraryContents); // Protobuild now returns with exit code 1 if you try to disable // a service that is required. this.Generate(args: "--disable Library/ServiceC", expectFailure: true); }
public void NoFeaturesEnabledWhenModuleHasNoFeaturesAndCommandLineFeaturesNotSpecified() { var kernel = GetKernel(); var featureManager = kernel.Get <IFeatureManager>(); featureManager.LoadFeaturesFromCommandLine(null); featureManager.LoadFeaturesFromSpecificModule(new ModuleInfo { FeatureSet = new List <Feature>() }); _assert.False(featureManager.IsFeatureEnabled(Feature.PackageManagement)); _assert.False(featureManager.IsFeatureEnabled(Feature.HostPlatformGeneration)); }
public void GenerationIsCorrect() { this.SetupTest("ServicesDependenciesPlatforms"); this.Generate("Windows"); _assert.True(File.Exists(this.GetPath(@"Console\Console.Windows.csproj"))); _assert.True(File.Exists(this.GetPath(@"Module.Windows.sln"))); _assert.True(File.Exists(this.GetPath(@"Submodule\Library\Library.Windows.csproj"))); _assert.True(File.Exists(this.GetPath(@"Submodule\Submodule.Windows.sln"))); var moduleContents = this.ReadFile(@"Module.Windows.sln"); var submoduleContents = this.ReadFile(@"Submodule\Submodule.Windows.sln"); _assert.Contains("Console.Windows.csproj", moduleContents); _assert.Contains("Library.Windows.csproj", moduleContents); _assert.Contains("Library.Windows.csproj", submoduleContents); this.Generate("Linux"); _assert.True(File.Exists(this.GetPath(@"Console\Console.Linux.csproj"))); _assert.True(File.Exists(this.GetPath(@"Module.Linux.sln"))); _assert.False(File.Exists(this.GetPath(@"Submodule\Library\Library.Linux.csproj"))); _assert.True(File.Exists(this.GetPath(@"Submodule\Submodule.Linux.sln"))); moduleContents = this.ReadFile(@"Module.Linux.sln"); submoduleContents = this.ReadFile(@"Submodule\Submodule.Linux.sln"); _assert.Contains("Console.Linux.csproj", moduleContents); _assert.DoesNotContain("Library.Linux.csproj", moduleContents); _assert.DoesNotContain("Library.Linux.csproj", submoduleContents); }
public void GenerationIsCorrect() { this.SetupTest("ServicesEnable"); this.Generate(); _assert.True(File.Exists(this.GetPath(@"Console\Console.Windows.csproj"))); _assert.False(File.Exists(this.GetPath(@"Submodule\Library\Library.Windows.csproj"))); var consoleContents = this.ReadFile(@"Console\Console.Windows.csproj"); _assert.DoesNotContain("CONSOLE_SERVICE_A;", consoleContents); this.Generate(args: "--enable Console/ServiceA"); _assert.True(File.Exists(this.GetPath(@"Console\Console.Windows.csproj"))); _assert.True(File.Exists(this.GetPath(@"Submodule\Library\Library.Windows.csproj"))); consoleContents = this.ReadFile(@"Console\Console.Windows.csproj"); var libraryContents = this.ReadFile(@"Submodule\Library\Library.Windows.csproj"); _assert.Contains("CONSOLE_SERVICE_A;", consoleContents); _assert.Contains("LIBRARY_SERVICE_B;", libraryContents); this.Generate(args: "--enable Library/ServiceB"); _assert.True(File.Exists(this.GetPath(@"Console\Console.Windows.csproj"))); _assert.True(File.Exists(this.GetPath(@"Submodule\Library\Library.Windows.csproj"))); consoleContents = this.ReadFile(@"Console\Console.Windows.csproj"); libraryContents = this.ReadFile(@"Submodule\Library\Library.Windows.csproj"); _assert.DoesNotContain("CONSOLE_SERVICE_A;", consoleContents); _assert.Contains("LIBRARY_SERVICE_B;", libraryContents); }
public void CommandRunsSuccessfully() { this.SetupTest("PackageUnifiedNuGetLocalInstallNoDedup"); if (File.Exists(this.GetPath(Path.Combine("Build", "Module.xml")))) { File.Delete(this.GetPath(Path.Combine("Build", "Module.xml"))); } using (var reader = new StreamReader(this.GetPath(Path.Combine("Build", "Module.Template.xml")))) { var content = reader.ReadToEnd(); content = content.Replace("{PATH_TO_NUGET_PKG}", SecurityElement.Escape(this.GetPath("Protoinject.nupkg"))); using (var writer = new StreamWriter(this.GetPath(Path.Combine("Build", "Module.xml")))) { writer.Write(content); } } if (Directory.Exists(this.GetPath("TestInstall"))) { PathUtils.AggressiveDirectoryDelete(this.GetPath("TestInstall")); } this.OtherMode("resolve", "Windows"); _assert.True(Directory.Exists(this.GetPath("TestInstall"))); _assert.True(Directory.Exists(this.GetPath(Path.Combine("TestInstall", "Windows")))); _assert.False(Directory.Exists(this.GetPath(Path.Combine("TestInstall", "Windows", "_rels")))); _assert.True(Directory.Exists(this.GetPath(Path.Combine("TestInstall", "Windows", "Build")))); }
public void GenerationIsCorrect() { this.SetupTest("SafeResolveDefaultsWithFeatureSet"); if (Directory.Exists(this.GetPath("Package"))) { PathUtils.AggressiveDirectoryDelete(this.GetPath("Package")); } var src = this.SetupSrcPackage(); try { Directory.CreateDirectory(GetPath("Package")); File.Copy(GetPath("PackageTemp\\Test.txt"), GetPath("Package\\Test.txt")); this.Generate(args: "--redirect http://protobuild.org/hach-que/TestEmptyPackage local-git://" + src); _assert.False(File.Exists(GetPath("Package\\Test.txt"))); _assert.True(Directory.Exists(GetPath("Package\\.git"))); } finally { PathUtils.AggressiveDirectoryDelete(src); if (Directory.Exists(this.GetPath("Package"))) { PathUtils.AggressiveDirectoryDelete(this.GetPath("Package")); } } }
public void GenerationIsCorrect() { this.SetupTest("SubmoduleGenerationSkippedIfNoStandardProjects"); var output = this.Generate(capture: true); _assert.False(File.Exists(this.GetPath("Submodule\\Submodule.Windows.sln"))); _assert.Contains("Skipping submodule generation for Submodule (there are no projects to generate)", output.Item1); }
public void GenerationIsCorrect() { this.SetupTest("PackageResolutionDoesNotOccurInFolderWithExistingData"); var src = this.SetupSrcPackage(); try { this.Generate(args: "--redirect http://protobuild.org/hach-que/TestEmptyPackage local-git://" + src); _assert.True(File.Exists(this.GetPath("Package\\empty.txt"))); _assert.False(File.Exists(this.GetPath("Package\\.pkg"))); _assert.False(File.Exists(this.GetPath("Package\\.git"))); _assert.False(Directory.Exists(this.GetPath("Package\\.git"))); } finally { PathUtils.AggressiveDirectoryDelete(src); } }
public void GeneratedTemplateIsCorrect() { this.SetupTest("PackageTemplateIgnoresTemplateOnlyFolder", true); // Make sure the Generated directory is removed so we have a clean test every time. if (Directory.Exists(this.GetPath("Generated"))) { PathUtils.AggressiveDirectoryDelete(this.GetPath("Generated")); } Directory.CreateDirectory(GetPath("Generated")); var templateFolder = this.SetupSrcTemplate(); this.OtherMode( "start", "local-template-git://" + templateFolder, workingSubdirectory: "Generated"); _assert.False(Directory.Exists(GetPath(Path.Combine("Generated", "_TemplateOnly")))); _assert.False(File.Exists(GetPath(Path.Combine("Generated", "_TemplateOnly")))); }
/// <summary> /// Test that a small piece of data can be sent over the unreliable protocol. /// </summary> public void TestLostIsNotTriggered() { const string Text = @"hello"; var udpClient1 = new UdpClient(0); var udpClient2 = new UdpClient(0); var dispatcher1 = new MxDispatcher(udpClient1); var dispatcher2 = new MxDispatcher(udpClient2); var port1 = ((IPEndPoint)udpClient1.Client.LocalEndPoint).Port; var port2 = ((IPEndPoint)udpClient2.Client.LocalEndPoint).Port; try { string receivedText = null; bool lost = false; var bytes = Encoding.ASCII.GetBytes(Text); dispatcher1.MessageReceived += (sender, args) => { receivedText = Encoding.ASCII.GetString(args.Payload); }; dispatcher2.MessageLost += (sender, args) => { if (args.Payload == bytes) { lost = true; } }; var client = dispatcher2.Connect(new IPEndPoint(IPAddress.Loopback, port1)); var clientGroup = dispatcher2.PlaceInGroup(client, "Group2"); this.SimulateNetworkCycles(4, dispatcher1, dispatcher2); dispatcher2.Send(clientGroup, bytes); _assert.Null(receivedText); this.SimulateNetworkCycles(8, dispatcher1, dispatcher2); _assert.Equal(Text, receivedText); _assert.False(lost); } finally { dispatcher1.Close(); dispatcher2.Close(); } }
public void GenerationIsCorrect() { this.SetupTest("IncludeProjectViaSubmoduleWorks"); this.Generate("Windows"); _assert.True(File.Exists(this.GetPath(@"Module.Windows.sln"))); _assert.True(File.Exists(this.GetPath(@"Console\Console.Windows.csproj"))); _assert.False(File.Exists(this.GetPath(@"Submodule\IncludableA\IncludableA.Windows.csproj"))); _assert.False(File.Exists(this.GetPath(@"Submodule\IncludableB\IncludableB.Windows.csproj"))); var projectContents = this.ReadFile(@"Console\Console.Windows.csproj"); _assert.Contains("<Link>Included Code\\Submodule/IncludableA\\MyIncludableClass.cs</Link>", projectContents); _assert.Contains("<Link>Included Code\\Submodule/IncludableB\\MyIncludableClass.cs</Link>", projectContents); _assert.Contains("<FromIncludeProject>", projectContents); _assert.Contains("..\\Submodule\\IncludableA\\MyIncludableClass.cs", projectContents); _assert.Contains("..\\Submodule\\IncludableB\\MyIncludableClass.cs", projectContents); _assert.DoesNotContain("<Reference Include=\"IncludableA\" />", projectContents); _assert.DoesNotContain("<Reference Include=\"IncludableB\" />", projectContents); _assert.DoesNotContain("<Reference Include=\"External\" />", projectContents); }
public void GenerationIsCorrect() { this.SetupTest("IncludeProjectReferencesWorks"); this.Generate("Windows"); _assert.True(File.Exists(this.GetPath(@"Module.Windows.sln"))); _assert.True(File.Exists(this.GetPath(@"Console\Console.Windows.csproj"))); _assert.False(File.Exists(this.GetPath(@"Includable\Includable.Windows.csproj"))); var projectContents = this.ReadFile(@"Console\Console.Windows.csproj"); _assert.Contains("<Reference Include=\"MyGACAssembly\"", projectContents); }
public void GenerationIsCorrect() { this.SetupTest("IncludeProjectPropertiesWorks"); this.Generate("Windows"); _assert.True(File.Exists(this.GetPath(@"Module.Windows.sln"))); _assert.True(File.Exists(this.GetPath(@"Console\Console.Windows.csproj"))); _assert.False(File.Exists(this.GetPath(@"Includable\Includable.Windows.csproj"))); var projectContents = this.ReadFile(@"Console\Console.Windows.csproj"); _assert.Contains("<NoWarn>TEST", projectContents); }
public void GenerationIsCorrect(string parent, string child) { this.SetupTest("ExampleCocos2DXNA", parent: parent, child: child); // Newer versions of Protobuild upgrade this file, but for regression testing we need the old // format (it's expected that the old format will be used in conjunction with old versions of // Protobuild, which are the version that we're regression testing with). Copy across // the old version before the start of every test here. File.Copy(this.GetPath(@"Build\ModuleOldFormat.xml"), this.GetPath(@"Build\Module.xml"), true); File.Copy(this.GetPath(@"MonoGame\Build\ModuleOldFormat.xml"), this.GetPath(@"MonoGame\Build\Module.xml"), true); try { this.Generate("Windows"); _assert.True(File.Exists(this.GetPath(@"Cocos2DXNA.Windows.sln"))); _assert.True(File.Exists(this.GetPath(@"Cocos2DXNA\Cocos2DXNA.Windows.csproj"))); _assert.False(File.Exists(this.GetPath(@"MonoGame\MonoGame.Framework\MonoGame.Framework.Windows.csproj"))); var gameContents = this.ReadFile(@"Cocos2DXNA\Cocos2DXNA.Windows.csproj"); var solutionContents = this.ReadFile(@"Cocos2DXNA.Windows.sln"); _assert.Contains("Microsoft.Xna.Framework", gameContents); _assert.DoesNotContain("MonoGame.Framework.Windows", gameContents); _assert.DoesNotContain("MonoGame.Framework.Windows", solutionContents); this.Generate("Linux"); _assert.True(File.Exists(this.GetPath(@"Cocos2DXNA.Linux.sln"))); _assert.True(File.Exists(this.GetPath(@"Cocos2DXNA\Cocos2DXNA.Linux.csproj"))); _assert.True(File.Exists(this.GetPath(@"MonoGame\MonoGame.Framework\MonoGame.Framework.Linux.csproj"))); gameContents = this.ReadFile(@"Cocos2DXNA\Cocos2DXNA.Linux.csproj"); solutionContents = this.ReadFile(@"Cocos2DXNA.Linux.sln"); _assert.DoesNotContain("Microsoft.Xna.Framework", gameContents); _assert.Contains("MonoGame.Framework.Linux", gameContents); _assert.Contains("MonoGame.Framework.Linux", solutionContents); } finally { // Reset the module info back to it's original state so we don't have a dirty working copy. File.Copy(this.GetPath(@"Build\ModuleOldFormat.xml"), this.GetPath(@"Build\Module.xml"), true); File.Copy(this.GetPath(@"MonoGame\Build\ModuleOldFormat.xml"), this.GetPath(@"MonoGame\Build\Module.xml"), true); } }
/// <summary> /// Test that a small piece of data can be sent over the unreliable protocol. /// </summary> public void TestLostIsNotTriggered() { const string Text = @"hello"; var dispatcher1 = new MxDispatcher(9027); var dispatcher2 = new MxDispatcher(9029); try { string receivedText = null; bool lost = false; var bytes = Encoding.ASCII.GetBytes(Text); dispatcher1.MessageReceived += (sender, args) => { receivedText = Encoding.ASCII.GetString(args.Payload); }; dispatcher2.MessageLost += (sender, args) => { if (args.Payload == bytes) { lost = true; } }; dispatcher2.Connect(new IPEndPoint(IPAddress.Loopback, 9027)); this.SimulateNetworkCycles(4, dispatcher1, dispatcher2); dispatcher2.Send(new IPEndPoint(IPAddress.Loopback, 9027), bytes); _assert.Null(receivedText); this.SimulateNetworkCycles(8, dispatcher1, dispatcher2); _assert.Equal(Text, receivedText); _assert.False(lost); } finally { dispatcher1.Close(); dispatcher2.Close(); } }
public void GenerationIsCorrect() { this.SetupTest("ServicesLibraryNotBuiltWhenNotUsed"); this.Generate(); _assert.True(File.Exists(this.GetPath(@"Console\Console.Windows.csproj"))); _assert.True(File.Exists(this.GetPath(@"Module.Windows.sln"))); _assert.False(File.Exists(this.GetPath(@"Submodule\Library\Library.Windows.csproj"))); _assert.True(File.Exists(this.GetPath(@"Submodule\Submodule.Windows.sln"))); var moduleContents = this.ReadFile(@"Module.Windows.sln"); var submoduleContents = this.ReadFile(@"Submodule\Submodule.Windows.sln"); _assert.Contains("Console.Windows.csproj", moduleContents); _assert.DoesNotContain("Library.Windows.csproj", moduleContents); _assert.DoesNotContain("Library.Windows.csproj", submoduleContents); }
public void GenerationIsCorrect() { this.SetupTest("InfoPListFileIsNotGeneratedWhenIncludeProvidesIt"); var infoPList = this.GetPath(@"Console\Info.plist"); if (File.Exists(infoPList)) { File.Delete(infoPList); } this.Generate("MacOS", hostPlatform: "MacOS"); _assert.True(File.Exists(this.GetPath(@"Console\Console.MacOS.csproj"))); _assert.False(File.Exists(infoPList)); var consoleContents = this.ReadFile(@"Console\Console.MacOS.csproj"); _assert.DoesNotContain("<None Include=\"Info.plist\"", consoleContents); }
/// <summary> /// <see cref="IAssert{TAssert}.Current"/>为<see cref="bool.FalseString"/> /// </summary> /// <param name="assert"></param> /// <returns></returns> public static IAssert <bool> False(this IAssert <bool> assert) => assert.False($"{assert.Name},不满足false条件");
public void IsNotOverlappingWhenNoBoundingBoxes() { var kernel = new StandardKernel(); kernel.Load <ProtogameCoreModule>(); var boundingBoxUtilities = kernel.Get <IBoundingBoxUtilities>(); _assert.False(boundingBoxUtilities.Overlaps()); }