public void FormatPrice_WithWholeNumberPrice_AddsDecimals() { //arrange MockReport report = new MockReport(); double price = 13; string expectedPrice = "13.00"; //act string actualPrice = report.FormatPrice(price); //assert Assert.AreEqual(expectedPrice, actualPrice, "Decimal places not correctly added to price"); }
public void FormatPrice_WithExtraDecimalPlace_RemovesDecimal() { //arrange MockReport report = new MockReport(); double price = 8.111; string expectedPrice = "8.11"; //act string actualPrice = report.FormatPrice(price); //assert Assert.AreEqual(expectedPrice, actualPrice, "Decimal places not correctly remove from price"); }
public void NotAllowedCommandNamesAreReportedAndTheBuildFails() { var project = Runtime.Project.GetProject(@"{ ""commands"" : { ""dnx"":""demo"" } }", @"foo", @"c:\foo\project.json"); var errorReport = new MockReport(); var builder = new InstallBuilder( project, null, new Reports() { Error = errorReport }); Assert.False(builder.Build(@"c:\foo")); Assert.Equal(1, errorReport.WriteLineCallCount); // TODO: Once we use resources, assert the full message Assert.True(errorReport.Messages.First().Contains("dnx")); }
public void NotAllowedCommandNamesAreReportedAndTheBuildFails() { var project = ProjectUtilities.GetProject(@"{ ""commands"" : { ""dnx"":""demo"" } }", @"foo", @"c:\foo\project.json"); var errorReport = new MockReport(); var builder = new InstallBuilder( project, null, new Reports() { Error = errorReport }); Assert.False(builder.Build(@"c:\foo")); Assert.Equal(1, errorReport.WriteLineCallCount); // TODO: Once we use resources, assert the full message Assert.True(errorReport.Messages.First().Contains("dnx")); }
public void ApplicationScriptsHaveTheCorrectContent() { using (DisposableDir tempDir = new DisposableDir()) { string testDir = Path.Combine(tempDir, "TestApp"); Directory.CreateDirectory(testDir); string projectFilePath = Path.Combine(testDir, "project.json"); string projectFileContent = @"{ ""commands"" : { ""cmd1"":""demo1"", ""cmd2"":""demo2"" } }"; File.WriteAllText(projectFilePath, projectFileContent); Runtime.Project project; Runtime.Project.TryGetProject(projectFilePath, out project); var packageManager = new MockPackageManager(); var infoReport = new MockReport(); var builder = new InstallBuilder( project, packageManager, new Reports() { Information = infoReport, Verbose = new MockReport() }); Assert.True(builder.Build(testDir)); ValidateProjectFile(Path.Combine(testDir, "app", "project.json")); ValidateScriptFile(Path.Combine(testDir, "app", "cmd1.cmd")); ValidateScriptFile(Path.Combine(testDir, "app", "cmd2.cmd")); } }