public void CreateAndMapFileLocation() { SpecStep specStep = new SpecStep { Message = "Message", ErrorLocation = "file.js:10:12", Status = SpecStatus.Failed }; FileLocation fileLocation = new FileLocation("file.js", @"C:\content\file.js", 10, 12); Mock <IFileLocationParser> fileLocationParserMock = new Mock <IFileLocationParser>(); fileLocationParserMock.Setup(flp => flp.Parse("file.js:10:12")).Returns(fileLocation); Mock <IFileLocationMapper> fileLocationMapperMock = new Mock <IFileLocationMapper>(); fileLocationMapperMock.Setup(flm => flm.Map(fileLocation)).Returns <FileLocation>(fl => fl); SpecStepViewModel specStepViewModel = SpecStepViewModel.Create(specStep, fileLocationParserMock.Object, fileLocationMapperMock.Object); specStepViewModel.ShouldBeEquivalentTo(specStep, o => o.Excluding(si => si.PropertyPath.EndsWith("IsNotifying") || si.PropertyPath == "Trace" || si.PropertyPath == "ErrorLocation" || si.PropertyPath == "MappedLocation")); specStepViewModel.ErrorLocation.ShouldBeEquivalentTo(new { Filename = "file.js", FullPath = @"C:\content\file.js", LineNumber = 10, ColumnNumber = 12 }); specStepViewModel.MappedLocation.ShouldBeEquivalentTo(new { Filename = "file.js", FullPath = @"C:\content\file.js", LineNumber = 10, ColumnNumber = 12 }); }
public void SetStatusTest() { string guid1 = Guid.NewGuid().ToString(); string guid2 = Guid.NewGuid().ToString(); SpecStep[] steps = new SpecStep[] { new SpecStep() { Message = "Step 1 message", Status = SpecStatus.Passed, Trace = "Step 1 trace" }, new SpecStep() { Message = "Step 2 message", Status = SpecStatus.Failed, Trace = "Step 2 trace" } }; TestHelper.TestCollectionChanged <BindableDictionary <string, SpecStatusViewModel>, KeyValuePair <string, SpecStatusViewModel> >(_SpecOrSuiteViewModel.Statuses) .Action(c => _SpecOrSuiteViewModel.SetStatus(guid1, SpecStatus.Failed, 1)).Adds(CreateKeyValue(guid1, SpecStatus.Failed, 1, 0)).CountIs(1) .Action(c => _SpecOrSuiteViewModel.SetStatus(guid2, SpecStatus.Skipped, 2)).Adds(CreateKeyValue(guid2, SpecStatus.Skipped, 2, 0)).CountIs(2) .Action(c => _SpecOrSuiteViewModel.SetStatus(guid1, SpecStatus.Skipped, 3, steps, Mock.Of <IFileLocationParser>(), null)).DoesNoChange(); _SpecOrSuiteViewModel.Statuses.ShouldAllBeEquivalentTo(new KeyValuePair <string, SpecStatusViewModel>[] { CreateKeyValue(guid1, SpecStatus.Skipped, 3, 2, steps), CreateKeyValue(guid2, SpecStatus.Skipped, 2, 0) }, o => o.Excluding(si => si.PropertyPath.EndsWith("IsNotifying"))); }
public void CreateWithMultilineTrace() { SpecStep specStep = new SpecStep { Trace = "Trace line 1\nTrace line 2" }; SpecStepViewModel specStepViewModel = SpecStepViewModel.Create(specStep, Mock.Of <IFileLocationParser>(), null); specStepViewModel.Trace.ShouldAllBeEquivalentTo(new object[] { SpecTraceStepViewModel.Create("Trace line 1", null, null), SpecTraceStepViewModel.Create("Trace line 2", null, null) }); }
public void CreateTest() { SpecStep specStep = new SpecStep { Message = "Message", Status = SpecStatus.Failed, Trace = "Trace" }; SpecStepViewModel specStepViewModel = SpecStepViewModel.Create(specStep, Mock.Of <IFileLocationParser>(), Mock.Of <IFileLocationMapper>()); specStepViewModel.ShouldBeEquivalentTo(specStep, o => o.Excluding(si => si.PropertyPath.EndsWith("IsNotifying") || si.PropertyPath == "Trace" || si.PropertyPath == "MappedLocation")); specStepViewModel.Trace.ShouldAllBeEquivalentTo(new object[] { SpecTraceStepViewModel.Create("Trace", null, null) }); }
public static SpecStepViewModel Create(SpecStep specStep, IFileLocationParser fileLocationParser, IFileLocationMapper fileLocationMapper) { SpecStepViewModel specStepViewModel = new SpecStepViewModel { Message = specStep.Message, ErrorLocation = fileLocationParser.Parse(specStep.ErrorLocation), Status = specStep.Status, Trace = ParseTrace(specStep.Trace, fileLocationParser, fileLocationMapper) }; if (specStepViewModel.ErrorLocation != null) { specStepViewModel.MappedLocation = fileLocationMapper.Map(specStepViewModel.ErrorLocation); } return(specStepViewModel); }
public void OutputStep(SpecStep specStep) { System.Console.WriteLine(String.Format("\tMessage: {0}, Status: {1}, Trace: {2}", specStep.Message, specStep.Status, specStep.Trace)); }