public void When_About_is_called_GetBand_on_IBandProcess_is_called_with_the_correct_parameter_and_the_result_is_mapped_with_BandMapper() { var entity = BandCreator.CreateSingle(); BandProcess .Expect(process => process.GetBand()) .Return(entity) .Repeat.Once(); BandProcess.Replay(); var detailModel = CreateAboutModel(); BandMapper .Expect(mapper => mapper.MapToAboutModel(entity)) .Return(detailModel) .Repeat.Once(); BandMapper.Replay(); var result = Controller.About().Result as ViewResult; Assert.IsNotNull(result); BandProcess.VerifyAllExpectations(); BandMapper.VerifyAllExpectations(); }
public void When_UpdateModel_is_mapped_to_an_Entity_and_the_Info_is_null_then_all_fields_are_mapped_correctly_and_Info_in_the_result_is_null() { var entity = BandCreator.CreateSingle(); BandProcess .Expect(process => process.GetBand()) .Return(entity) .Repeat.Once(); BandProcess.Replay(); var updateModel = new AboutUpdateModel { DateFounded = DateTime.Now.AddMonths(-4).Date, Info = null, }; var result = Mapper.Map(updateModel); Assert.AreEqual(entity.Id, result.Id, "Id not correct"); Assert.AreEqual(updateModel.DateFounded.ToUniversalTime(), result.Founded, "Date founded not correct"); Assert.AreEqual(null, result.Description, "Description not correct"); BandProcess.VerifyAllExpectations(); }
public void When_Band_is_mapped_to_a_DetailsModel_then_no_data_is_retrieved_from_process_classes() { BandProcess .Expect(process => process.GetBand()) .Repeat.Never(); BandProcess.Replay(); var entity = BandCreator.CreateSingle(); var result = Mapper.MapToAboutModel(entity); Assert.AreEqual(entity.Founded.ToLocalTime(), result.DateFounded); Assert.AreEqual(entity.Description, result.Info); }
public void When_Band_is_mapped_to_a_DetailsModel_and_the_Description_is_null_then_the_Info_is_stringEmpty() { BandProcess .Expect(process => process.GetBand()) .Repeat.Never(); BandProcess.Replay(); var entity = BandCreator.CreateSingle(); entity.Description = null; var result = Mapper.MapToAboutModel(entity); Assert.AreEqual(entity.Founded.ToLocalTime(), result.DateFounded); Assert.AreEqual(string.Empty, result.Info); }
public void When_CreatUser_is_called_then_the_User_is_created_and_registered_under_the_Band_that_is_provided_by_the_BandProcess() { var band = BandCreator.CreateSingle(); var user = UserCreator.CreateSingle(); var login = user.Login; const string encryptedPassword = "******"; BandProcess .Expect(process => process.EnsureBandExists()) .Return(band) .Repeat.Once(); BandProcess.Replay(); CryptographyProcess .Expect(process => process.Encrypt(login.Password)) .Return(encryptedPassword) .Repeat.Once(); CryptographyProcess.Replay(); UserProcess .Expect(process => process.GetUserByLoginName(Arg <string> .Is.Anything)) .Return(null) .Repeat.Once(); UserProcess .Expect(process => process.GetUserByEmailAddress(Arg <string> .Is.Anything)) .Return(null) .Repeat.Once(); UserProcess .Expect(process => process.AddUser(Arg <User> .Matches(u => u.BandId == band.Id && u.Login.Password == encryptedPassword && u.Login.IsOnline && u.Login.LastLoginDate > DateTime.UtcNow.AddSeconds(-2) && u.Login.LastActivityDate > DateTime.UtcNow.AddSeconds(-2) && u.Login.LastPasswordChangedDate > DateTime.UtcNow.AddSeconds(-2)))) .Return(user) .Repeat.Once(); UserProcess.Replay(); var membershipUser = CreateMembershipUser(user); UserMapper .Expect(mapper => mapper.Map(user)) .Return(membershipUser) .Repeat.Once(); UserMapper.Replay(); MembershipCreateStatus createStatus; var result = CustomMembershipProvider.CreateUser( login.LoginName, login.Password, login.EmailAddress, string.Empty, string.Empty, login.IsApproved, login.Id, out createStatus); Assert.IsNotNull(result); Assert.IsNotNull(result.ProviderUserKey); Assert.AreEqual(user.Login.LoginName, result.UserName); Assert.AreEqual(MembershipCreateStatus.Success, createStatus); BandProcess.VerifyAllExpectations(); CryptographyProcess.VerifyAllExpectations(); UserProcess.VerifyAllExpectations(); UserMapper.VerifyAllExpectations(); }