Beispiel #1
0
        public async Task CreateAsyncShouldCreateCitizenWithCorrectData()
        {
            var userId     = "testId";
            var inputModel = new AppUserInputModel
            {
                Birthdate = DateTime.Today,
                Sex       = true,
                FirstName = "Test Name",
                LastName  = "Test Surname",
            };

            await this.citizensService.CreateAsync(inputModel, userId);

            var citizen = this.citizensList.First();

            var birthday  = DateTime.Today.ToUniversalTime();
            var sex       = true;
            var firstName = "Test Name";
            var lastName  = "Test Surname";

            Assert.Equal(birthday, citizen.Birthdate);
            Assert.Equal(firstName, citizen.FirstName);
            Assert.Equal(lastName, citizen.LastName);
            Assert.Equal(sex, citizen.Sex);
        }
Beispiel #2
0
        public async Task CreateAsync(AppUserInputModel input, string userId)
        {
            var institution = new Institution
            {
                UserId       = userId,
                Name         = input.Name,
                WebsiteUrl   = input.Website,
                IsGovernment = input.IsGovernment == true ? true : false,
            };

            await this.institutionRepo.AddAsync(institution);

            await this.institutionRepo.SaveChangesAsync();
        }
Beispiel #3
0
        public async Task CreateAsyncShouldAddInstitutionToDb()
        {
            var userId     = "testId";
            var inputModel = new AppUserInputModel
            {
                Name         = "Test Name",
                Website      = "Test Site",
                IsGovernment = true,
            };

            await this.institutionsService.CreateAsync(inputModel, userId);

            Assert.True(this.institutionsList.Count() == 1);
        }
Beispiel #4
0
        public async Task CreateAsyncShouldAddCitizenToDb()
        {
            var userId     = "testId";
            var inputModel = new AppUserInputModel
            {
                Birthdate = DateTime.Today,
                Sex       = true,
                FirstName = "Test Name",
                LastName  = "Test Surname",
            };

            await this.citizensService.CreateAsync(inputModel, userId);

            Assert.True(this.citizensList.Count() == 1);
        }
Beispiel #5
0
        public async Task CreateAsync(AppUserInputModel input, string userId)
        {
            var citizen = new Citizen
            {
                UserId    = userId,
                FirstName = input.FirstName,
                LastName  = input.LastName,
                Birthdate = input.Birthdate?.ToUniversalTime(),
                Sex       = input.Sex,
            };

            await this.citizenRepo.AddAsync(citizen);

            await this.citizenRepo.SaveChangesAsync();
        }
Beispiel #6
0
        public async Task GetByUserIdShouldReturnCorrectCitizen()
        {
            var userId     = "testId";
            var inputModel = new AppUserInputModel
            {
                Birthdate = DateTime.Today,
                Sex       = true,
                FirstName = "Test Name",
                LastName  = "Test Surname",
            };

            await this.citizensService.CreateAsync(inputModel, userId);

            var citizen = this.citizensService.GetByUserId(userId);

            Assert.Equal(inputModel.FirstName, citizen.FirstName);
            Assert.Equal(inputModel.LastName, citizen.LastName);
        }
Beispiel #7
0
        public async Task CreateAsyncShouldCreateInstitutionWithCorrectData()
        {
            var userId     = "testId";
            var inputModel = new AppUserInputModel
            {
                Name         = "Test Name",
                Website      = "Test Site",
                IsGovernment = true,
            };

            await this.institutionsService.CreateAsync(inputModel, userId);

            var institution = this.institutionsList.First();

            Assert.Equal(inputModel.Name, institution.Name);
            Assert.Equal(inputModel.Website, institution.WebsiteUrl);
            Assert.Equal(inputModel.IsGovernment, institution.IsGovernment);
        }
Beispiel #8
0
        public async Task GetByUserIdShouldReturnCorrectInstitution()
        {
            var userId     = "testId";
            var inputModel = new AppUserInputModel
            {
                Name         = "Test Name",
                Website      = "Test Site",
                IsGovernment = true,
            };

            await this.institutionsService.CreateAsync(inputModel, userId);

            userId = "anotherId";
            await this.institutionsService.CreateAsync(inputModel, userId);

            var institution = this.institutionsService.GetByUserId(userId);

            Assert.Equal(institution.UserId, userId);
        }
Beispiel #9
0
        public async Task GetByIdShouldReturnCorrectInstitution()
        {
            var userId     = "testId";
            var inputModel = new AppUserInputModel
            {
                Name         = "Test Name",
                Website      = "Test Site",
                IsGovernment = true,
            };

            await this.institutionsService.CreateAsync(inputModel, userId);

            this.institutionsList.First().Id = 1;

            inputModel.Name = "Test Test";
            await this.institutionsService.CreateAsync(inputModel, userId);

            var institution = this.institutionsService.GetById(1);

            Assert.Equal("Test Name", institution.Name);
        }