コード例 #1
0
ファイル: IndexTests.cs プロジェクト: Coilz/BandWebsite
        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();
        }
コード例 #2
0
ファイル: DetailsTests.cs プロジェクト: Coilz/BandWebsite
        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();
        }
コード例 #3
0
ファイル: EditTests.cs プロジェクト: Coilz/BandWebsite
        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();
        }
コード例 #4
0
ファイル: EditTests.cs プロジェクト: Coilz/BandWebsite
        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();
        }
コード例 #5
0
        protected override void AdditionalSetup()
        {
            base.AdditionalSetup();

            Mapper = new PerformanceMapper(CatalogsContainer);
        }