예제 #1
0
        public async Task ChangeUserEthnicityWithNullUser_ShouldReturnStatusInvalidUser()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            var repository = new EfDeletableEntityRepository <ApplicationUser>(new ApplicationDbContext(options));

            var service = new ModelService.ModelService(repository, null, null, null);

            var user1 = await this.CreateUserAsync("*****@*****.**", "Pesho", "Peshev", repository);

            var user2 = await this.CreateUserAsync("*****@*****.**", "Vank", "Vanko", repository);

            var getUser = await repository.All().Where(x => x.Id == user1).FirstOrDefaultAsync();

            var changeTo      = Ethnicity.Japanese;
            var statusInvalid = "Invalid user";

            var changeUserEthnicity = await service.ChangeUserEthnicity(null, changeTo);

            var userCurrentEthnicitySecondCheck = getUser.ModelInformation.Ethnicity;

            Assert.Equal(statusInvalid, changeUserEthnicity);
            Assert.Equal(Ethnicity.Chinese, userCurrentEthnicitySecondCheck);
        }