public async Task Should_Not_Edit_User_Full_Name_If_Full_Name_Is_Not_Valid() { string testUserName = "******"; string testPassword = "******"; Result editCommandResult; var testUser = new User((Nickname)testUserName, (FullName)"test4 user4", Password.Create(testPassword).Value, (Email)"*****@*****.**", "bio4"); using (var session = _testFixture.OpenSession(_output)) { await session.SaveAsync(testUser); } var command = new EditUserDetailsCommand( testUser.ID, testUser.Nickname, string.Empty, string.Empty, testUser.Email, testUser.Biography, testUser.ProfilePicture); using (var session = _testFixture.OpenSession(_output)) { var sut = new EditUserDetailsCommandHandler(session, Log.Logger); editCommandResult = await sut.Handle(command, default); } editCommandResult.IsSuccess.Should().BeFalse(); }
public async Task Should_Edit_Registered_User_Information() { string testUserName = "******"; string testPassword = "******"; Result editCommandResult; var testUser = new User((Nickname)testUserName, (FullName)"test1 user1", Password.Create(testPassword).Value, (Email)"*****@*****.**", "bio1"); using (var session = _testFixture.OpenSession(_output)) { await session.SaveAsync(testUser); } var command = new EditUserDetailsCommand( testUser.ID, $"{testUser.Nickname}_mod", $"{testUser.FullName.Name}_mod", $"{testUser.FullName.Surname}_mod", "*****@*****.**", "new bio", Convert.FromBase64String(_testFixture.GetTestPictureBase64())); using (var session = _testFixture.OpenSession(_output)) { var sut = new EditUserDetailsCommandHandler(session, Log.Logger); editCommandResult = await sut.Handle(command, default); } using (new AssertionScope()) { editCommandResult.IsSuccess.Should().BeTrue(); using (var session = _testFixture.OpenSession(_output)) { var modifiedUser = await session.GetAsync <User>(testUser.ID); modifiedUser.Nickname.Should().Be((Nickname)$"{testUser.Nickname}_mod"); modifiedUser.FullName.Should().Be((FullName)$"{testUser.FullName.Name}_mod {testUser.FullName.Surname}_mod"); modifiedUser.Email.Should().Be((Email)"*****@*****.**"); modifiedUser.Biography.Should().Be("new bio"); modifiedUser.ProfilePicture.Should().Be((Picture)_testFixture.GetTestPictureBase64()); } } }