コード例 #1
0
        protected override void AdditionalSetup()
        {
            base.AdditionalSetup();

            PhotoAdapter = MockHelper.CreateAndRegisterMock<IPhotoAdapter>();
            Process = new PhotoProcess(CatalogsContainer);
        }
コード例 #2
0
        protected override void AdditionalSetup()
        {
            base.AdditionalSetup();

            PhotoAdapter = MockHelper.CreateAndRegisterMock <IPhotoAdapter>();
            Process      = new PhotoProcess(CatalogsContainer);
        }
コード例 #3
0
ファイル: EditTests.cs プロジェクト: Coilz/BandWebsite
        public void When_Edit_is_called_with_an_Id_then_GetPhotoAdapterSettings_on_IPhotoAdapterSettingsProcess_is_called_and_the_result_is_mapped_with_PhotoAdapterSettingsMapper()
        {
            var photoAdapterSettings = AdapterSettingsCreator.CreateSingle();

            PhotoProcess
            .Expect(process =>
                    process.GetAdapterSettings())
            .Return(photoAdapterSettings)
            .Repeat.Once();
            PhotoProcess.Replay();

            var updateModel = CreateUpdatePhotoAdapterSettingsModel(Guid.NewGuid());

            PhotoAdapterSettingsMapper
            .Expect(mapper =>
                    mapper.MapToUpdate(
                        Arg <AdapterSettings> .Matches(settings => settings.Id == photoAdapterSettings.Id)))
            .Return(updateModel)
            .Repeat.Once();
            PhotoAdapterSettingsMapper.Replay();

            var result = Controller.Edit().Result as ViewResult;

            Assert.IsNotNull(result);

            var model = result.Model as UpdatePhotoAdapterSettingsModel;

            Assert.IsNotNull(model);

            PhotoProcess.VerifyAllExpectations();
            PhotoAdapterSettingsMapper.VerifyAllExpectations();
        }
コード例 #4
0
        public void When_UpdatePhotoAdapterSettings_is_mapped_to_a_PhotoAdapterSettings_and_the_SetName_is_null_then_all_fields_are_mapped_correctly_and_SetName_in_the_result_is_null()
        {
            const string fullName = "FullName";
            const string userName = "******";
            const string userId   = "UserId";

            var entity = AdapterSettingsCreator.CreateSingle();

            PhotoProcess
            .Expect(process =>
                    process.GetAdapterSettings())
            .Return(entity)
            .Repeat.Once();
            PhotoProcess.Replay();

            var updateModel = new UpdatePhotoAdapterSettingsModel
            {
                FullName = fullName,
                UserName = userName,
                UserId   = userId,
                SetName  = null,
            };

            var result = Mapper.Map(updateModel);

            Assert.AreEqual(null, result.SetName);
            Assert.AreNotEqual(fullName, result.OAuthAccessToken.FullName);
            Assert.AreNotEqual(userName, result.OAuthAccessToken.Username);
            Assert.AreNotEqual(userId, result.OAuthAccessToken.UserId);

            PhotoProcess.VerifyAllExpectations();
        }
コード例 #5
0
ファイル: EditTests.cs プロジェクト: Coilz/BandWebsite
        public void When_Edit_is_called_with_a_model_then_Map_on_PhotoAdapterSettingsMapper_is_called_and_the_result_is_used_to_call_UpdatePhotoAdapterSettings_on_IPhotoAdapterSettingsProcess_with()
        {
            var photoAdapterSettings = AdapterSettingsCreator.CreateSingle();

            PhotoProcess
            .Expect(process =>
                    process.UpdateAdapterSettings(
                        Arg <AdapterSettings> .Matches(settings =>
                                                       settings.Id == photoAdapterSettings.Id)))
            .Return(photoAdapterSettings)
            .Repeat.Once();
            PhotoProcess.Replay();

            var updateModel = CreateUpdatePhotoAdapterSettingsModel(photoAdapterSettings.Id);

            PhotoAdapterSettingsMapper
            .Expect(mapper =>
                    mapper.Map(
                        Arg <UpdatePhotoAdapterSettingsModel> .Matches(m => m.SetName == photoAdapterSettings.SetName)))
            .Return(photoAdapterSettings)
            .Repeat.Once();
            PhotoAdapterSettingsMapper.Replay();

            var result = Controller.Edit(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);
            }

            PhotoProcess.VerifyAllExpectations();
            PhotoAdapterSettingsMapper.VerifyAllExpectations();
        }