public async Task AddUserTest_ShouldAddUserToDb() { // Given var options = TestHelper.optionsFactory("add_user_db"); var expectedUser = new UserModel() { Id = new Guid(), FirstName = "Steven", LastName = "Universe", Username = "******", ExternalId = 1, CreatedAtUtc = DateTime.UtcNow, IsActive = true }; var message = new MessageCommand() { FirstName = expectedUser.FirstName, LastName = expectedUser.LastName, Username = expectedUser.Username, ExternalUserId = expectedUser.ExternalId }; // When using (var context = new MusichinoDbContext(options)) { var service = new UserService(context); await service.AddUser(message); var actualUser = await context.Users.FirstOrDefaultAsync(); // Then Assert.NotEmpty(context.Users); Assert.NotNull(actualUser); Assert.Equal(expectedUser.FirstName, actualUser.FirstName); Assert.Equal(expectedUser.LastName, actualUser.LastName); Assert.Equal(expectedUser.Username, actualUser.Username); Assert.Equal(expectedUser.ExternalId, actualUser.ExternalId); Assert.Equal(expectedUser.IsActive, actualUser.IsActive); } }
public void AddUser_ShouldAddUser() { userService.AddUser("Seppe"); repository.Received().AddUser(Arg.Is <User>(x => x.Name.Equals("Seppe") && x.ID == 1)); }