public async Task InsertModelInformation_CallingTheMethodTwiceShouldReturnRightStatusMassages() { string infoUpdate = "User Information Updated"; string infoCreated = "User Information was created"; var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var userRepository = new EfDeletableEntityRepository <ApplicationUser>(new ApplicationDbContext(options)); var modelInfoRepository = new EfDeletableEntityRepository <ModelInformation>(new ApplicationDbContext(options)); var service = new ModelService.ModelService(userRepository, null, null, modelInfoRepository); var user1 = await this.CreateUserWithNoInformationAsync("*****@*****.**", "Pesho", "Peshev", userRepository); var user2 = await this.CreateUserWithNoInformationAsync("*****@*****.**", "Vank", "Vanko", userRepository); var response = await service.InsertModelInformation(user1); var response2 = await service.InsertModelInformation(user1); Assert.Equal(infoCreated, response); Assert.Equal(infoUpdate, response2); }
public async Task InsertModelInformation_ShouldAddFillTablesWithDefaultInformation() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var userRepository = new EfDeletableEntityRepository <ApplicationUser>(new ApplicationDbContext(options)); var modelInfoRepository = new EfDeletableEntityRepository <ModelInformation>(new ApplicationDbContext(options)); var service = new ModelService.ModelService(userRepository, null, null, modelInfoRepository); var user1 = await this.CreateUserWithNoInformationAsync("*****@*****.**", "Pesho", "Peshev", userRepository); var user2 = await this.CreateUserWithNoInformationAsync("*****@*****.**", "Vank", "Vanko", userRepository); await service.InsertModelInformation(user1); var check = await modelInfoRepository.All().Where(x => x.UserId == user1).FirstOrDefaultAsync(); Assert.NotNull(check); }