public void When_Performance_is_mapped_to_a_PerformanceDetailsModel_and_the_venueUri_is_null_then_the_resultUrl_is_stringEmpty() { PerformanceProcess .Expect(process => process.GetPerformance(Arg <Guid> .Is.Anything)) .Repeat.Never(); PerformanceProcess.Replay(); var entity = PerformanceCreator.CreateSingleFuture(); entity.VenueUri = null; var result = Mapper.MapToDetail(entity); Assert.AreEqual(entity.Id, result.Id); Assert.AreEqual(entity.CreationDate, result.CreationDate); Assert.AreEqual(entity.ModificationDate, result.ModificationDate); Assert.AreEqual(entity.StartDateTime.Date.ToLocalTime(), result.Date); Assert.AreEqual(entity.StartDateTime.ToLocalTime(), result.StartTime); Assert.AreEqual(entity.EndDateTime.ToLocalTime(), result.EndTime); Assert.AreEqual(entity.City, result.City); Assert.AreEqual(entity.VenueName, result.VenueName); Assert.AreEqual(string.Empty, result.VenueUrl); Assert.AreEqual(entity.Info, result.Info); Assert.AreEqual(entity.Price, result.Price); }
public void When_Performance_is_mapped_to_a_PerformanceDetailsModel_then_no_data_is_retrieved_from_process_classes() { PerformanceProcess .Expect(process => process.GetPerformance(Arg <Guid> .Is.Anything)) .Repeat.Never(); PerformanceProcess.Replay(); var entity = PerformanceCreator.CreateSingleFuture(); var result = Mapper.MapToDetail(entity); Assert.AreEqual(entity.Id, result.Id); Assert.AreEqual(entity.CreationDate, result.CreationDate); Assert.AreEqual(entity.ModificationDate, result.ModificationDate); Assert.AreEqual(entity.StartDateTime.Date.ToLocalTime(), result.Date); Assert.AreEqual(entity.StartDateTime.ToLocalTime(), result.StartTime); Assert.AreEqual(entity.EndDateTime.ToLocalTime(), result.EndTime); Assert.AreEqual(entity.City, result.City); Assert.AreEqual(entity.VenueName, result.VenueName); Assert.AreEqual(entity.VenueUri.OriginalString, result.VenueUrl); Assert.AreEqual(entity.Info, result.Info); Assert.AreEqual(entity.Price, result.Price); }
public void When_a_list_of_Performances_is_mapped_to_a_PerformanceDetailsModels_then_no_data_is_retrieved_from_process_classes() { PerformanceProcess .Expect(process => process.GetPerformance(Arg <Guid> .Is.Anything)) .Repeat.Never(); PerformanceProcess.Replay(); var entities = PerformanceCreator.CreateFutureCollection(); var result = Mapper.Map(entities); foreach (var entity in entities) { Assert.IsTrue(result.Items .Single(model => model.Id == entity.Id && model.ModificationDate == entity.ModificationDate && model.CreationDate == entity.CreationDate && model.Date == entity.StartDateTime.Date.ToLocalTime() && model.StartTime == entity.StartDateTime.ToLocalTime() && model.EndTime == entity.EndDateTime.ToLocalTime() && model.City == entity.City && model.Info == entity.Info && model.Price == entity.Price && model.VenueName == entity.VenueName && model.VenueUrl == entity.VenueUri.OriginalString) != null); } }
public void When_Delete_is_called_with_an_Id_then_GetPerformance_on_IPerformanceProcess_is_called_and_the_result_used_to_call_RemovePerformance_on_IPerformanceProcess() { var entity = PerformanceCreator.CreateSingleFuture(); PerformanceProcess .Expect(process => process.GetPerformance(entity.Id)) .Return(entity) .Repeat.Once(); PerformanceProcess .Expect(process => process.RemovePerformance(entity)) .Repeat.Once(); PerformanceProcess.Replay(); var result = Controller.Delete(entity.Id).Result as RedirectToRouteResult; Assert.IsNotNull(result); var routeValues = result.RouteValues; Assert.AreEqual(1, routeValues.Count); foreach (var routeValue in routeValues) { Assert.AreEqual("action", routeValue.Key); Assert.AreEqual("Index", routeValue.Value); } PerformanceProcess.VerifyAllExpectations(); }
public void When_Index_is_called_GetPerformances_on_IPerformanceProcess_is_called_and_the_result_is_mapped_with_PerformanceMapper() { var performances = PerformanceCreator.CreateFutureCollection(); PerformanceProcess .Expect(process => process.GetPerformances()) .Return(performances) .Repeat.Once(); PerformanceProcess.Replay(); var performanceDetailsModelcollection = CreatePerformanceDetailsModelCollection(); PerformanceMapper .Expect(mapper => mapper.Map( Arg <IEnumerable <Performance> > .Matches(articles => performances.All(performance => articles.Any(article => article.Id == performance.Id))))) .Return(performanceDetailsModelcollection) .Repeat.Once(); PerformanceMapper.Replay(); var result = Controller.Future().Result as PartialViewResult; Assert.IsNotNull(result); var model = result.Model as ItemListModel <PerformanceDetailsModel>; Assert.IsNotNull(model); PerformanceProcess.VerifyAllExpectations(); PerformanceMapper.VerifyAllExpectations(); }
public void When_Details_is_called_GetPerformance_on_IPerformanceProcess_is_called_with_the_correct_parameter_and_the_result_is_mapped_with_PerformanceMapper() { var performance = PerformanceCreator.CreateSingleFuture(); PerformanceProcess .Expect(process => process.GetPerformance(performance.Id)) .Return(performance) .Repeat.Once(); PerformanceProcess.Replay(); var performanceDetailsModel = CreatePerformanceDetailsModel(performance.Id); PerformanceMapper .Expect(mapper => mapper.MapToDetail(performance)) .Return(performanceDetailsModel) .Repeat.Once(); PerformanceMapper.Replay(); var result = Controller.Details(performance.Id).Result as ViewResult; Assert.IsNotNull(result); PerformanceProcess.VerifyAllExpectations(); PerformanceMapper.VerifyAllExpectations(); }
public void When_Edit_is_called_with_an_Id_then_GetPerformance_on_IPerformanceProcess_is_called_and_the_result_is_mapped_with_PerformanceMapper() { var entity = PerformanceCreator.CreateSingleFuture(); PerformanceProcess .Expect(process => process.GetPerformance(entity.Id)) .Return(entity) .Repeat.Once(); PerformanceProcess.Replay(); var updateModel = CreateUpdatePerformanceModel(Guid.NewGuid()); PerformanceMapper .Expect(mapper => mapper.MapToUpdate( Arg <Performance> .Matches(settings => settings.Id == entity.Id))) .Return(updateModel) .Repeat.Once(); PerformanceMapper.Replay(); var result = Controller.Edit(entity.Id).Result as ViewResult; Assert.IsNotNull(result); var model = result.Model as UpdatePerformanceModel; Assert.IsNotNull(model); PerformanceProcess.VerifyAllExpectations(); PerformanceMapper.VerifyAllExpectations(); }
public IProcess CreateNextProcess(ProcessType prevProcessType) { IProcess nextProcess = null; switch (prevProcessType) { case ProcessType.Default: nextProcess = new PerformanceProcess(); break; case ProcessType.End: break; } return nextProcess; }
public void When_Edit_is_called_with_a_model_then_Map_on_PerformanceMapper_is_called_and_the_result_is_used_to_call_UpdatePerformance_on_IPerformanceProcess_with() { var entity = PerformanceCreator.CreateSingleFuture(); PerformanceProcess .Expect(process => process.UpdatePerformance( Arg <Performance> .Matches(settings => settings.Id == entity.Id))) .Return(entity) .Repeat.Once(); PerformanceProcess.Replay(); var updateModel = CreateUpdatePerformanceModel(entity.Id); PerformanceMapper .Expect(mapper => mapper.Map( Arg <UpdatePerformanceModel> .Matches(m => m.City == entity.City && m.VenueName == entity.VenueName), Arg <Guid> .Matches(guid => guid == entity.Id))) .Return(entity) .Repeat.Once(); PerformanceMapper.Replay(); var result = Controller.Edit(entity.Id, updateModel).Result as RedirectToRouteResult; Assert.IsNotNull(result); var routeValues = result.RouteValues; Assert.AreEqual(1, routeValues.Count); foreach (var routeValue in routeValues) { Assert.AreEqual("action", routeValue.Key); Assert.AreEqual("Index", routeValue.Value); } PerformanceProcess.VerifyAllExpectations(); PerformanceMapper.VerifyAllExpectations(); }
public void When_UpdatePerformance_is_mapped_to_a_Performance_and_the_VenueUrl_is_null_then_all_fields_are_mapped_correctly_and_VenueUri_in_the_result_is_null() { var startDateTime = DateTime.Now.AddDays(37); var endDateTime = startDateTime.AddHours(4); var entity = PerformanceCreator.CreateSingleFuture(); PerformanceProcess .Expect(process => process.GetPerformance(entity.Id)) .Return(entity) .Repeat.Once(); PerformanceProcess.Replay(); var updateModel = new UpdatePerformanceModel { Id = entity.Id, Date = startDateTime.Date, StartTime = startDateTime, EndTime = endDateTime, City = "City", Info = "Info", Price = DateTime.UtcNow.Ticks, VenueUrl = null, }; var result = Mapper.Map(updateModel, entity.Id); Assert.AreEqual(entity.Id, result.Id, "Id not correct"); Assert.AreEqual(updateModel.Date.ToString("ddMMyyyy", CultureInfo.InvariantCulture), result.StartDateTime.ToString("ddMMyyyy", CultureInfo.InvariantCulture), "StartDateTime not correct"); Assert.AreEqual(updateModel.StartTime.ToString("HHmm", CultureInfo.InvariantCulture), result.StartDateTime.ToString("HHmm", CultureInfo.InvariantCulture), "StartDateTime not correct"); Assert.AreEqual(updateModel.EndTime.ToString("HHmm", CultureInfo.InvariantCulture), result.EndDateTime.ToString("HHmm", CultureInfo.InvariantCulture), "EndDateTime not correct"); Assert.AreEqual(updateModel.City, result.City, "City not correct"); Assert.AreEqual(updateModel.Info, result.Info, "Info not correct"); Assert.AreEqual(updateModel.Price, result.Price, "Proce not correct"); Assert.AreEqual(updateModel.VenueName, result.VenueName, "VenueName not correct"); Assert.AreEqual(null, result.VenueUri, "VenueUri not correct"); PerformanceProcess.VerifyAllExpectations(); }
protected override void AdditionalSetup() { base.AdditionalSetup(); Process = new PerformanceProcess(CatalogsContainer); }