private void InitializeFixture() { DatabaseTestUtility.DropCreateMileageStatsDatabase(); this.defaultTestUser = new User() { AuthorizationId = "TestAuthorizationId", DisplayName = "DefaultTestUser" }; var repository = new UserRepository(new MileageStatsDbContext()); repository.Create(this.defaultTestUser); }
public void WhenAddingUser_ThenUserPersists() { DatabaseTestUtility.DropCreateMileageStatsDatabase(); var userRepository = new UserRepository(new MileageStatsDbContext()); var newUser = new User() { AuthorizationId = "AnAuthorizationId", DisplayName = "TheDisplayName", }; userRepository.Create(newUser); Assert.NotNull( new MileageStatsDbContext().Users.Where(u => u.AuthorizationId == newUser.AuthorizationId).Single()); }
public void WhenAddingUser_ThenUserReceivesNonZeroId() { DatabaseTestUtility.DropCreateMileageStatsDatabase(); var userRepository = new UserRepository(new MileageStatsDbContext()); var newUser = new User() { AuthorizationId = "AnAuthorizationId", DisplayName = "TheDisplayName", }; Assert.Equal(0, newUser.UserId); userRepository.Create(newUser); Assert.True(newUser.UserId > 0, "User did not receive non-zero UserId when persisted."); }
private void InitializeFixture() { DatabaseTestUtility.DropCreateMileageStatsDatabase(); this.defaultTestUser = new User() { AuthorizationId = "TestAuthorizationId", DisplayName = "DefaultTestUser" }; var userRepository = new UserRepository(this.GetUnitOfWork()); userRepository.Create(this.defaultTestUser); int userId = this.defaultTestUser.UserId; var vehicleRepository = new VehicleRepository(this.GetUnitOfWork()); this.defaultVehicle = new Vehicle() { Name = "Test Vehicle" }; vehicleRepository.Create(this.defaultTestUser.UserId, this.defaultVehicle); }
public void WhenAddingUser_ThenUserReturnsPopulatedNewUser() { DatabaseTestUtility.DropCreateMileageStatsDatabase(); var userRepository = new UserRepository(new MileageStatsDbContext()); string authorizationId = "AnAuthorizationId"; string displayName = "TheDisplayName"; var newUser = new User() { AuthorizationId = authorizationId, DisplayName = displayName, }; userRepository.Create(newUser); Assert.NotNull(newUser); Assert.Equal(1, newUser.UserId); Assert.Equal(authorizationId, newUser.AuthorizationId); Assert.Equal(displayName, newUser.DisplayName); }