Beispiel #1
0
        public async Task PostService_Success_Database()
        {
            var types = await CreateDefaultTypesAsync();

            var setup = await SetupServiceAsync();

            var model = new EventServiceModel
            {
                Id       = -1,
                PersonId = -1,
                Profile  = Guid.NewGuid().ToString(),
                Salary   = 10008,
                TypeId   = types.catererType.Id
            };

            var r = await _Client.PostAsync($"api/service/{setup.firstService.Id}", model.ToStringContent());

            r.EnsureSuccessStatusCode();

            var result = await CreateDataContext().EventService.FirstOrDefaultAsync(x => x.Id == setup.firstService.Id);

            Assert.NotNull(result);
            Assert.Equal(model.Profile, result.Profile);
            Assert.Equal(model.Salary, result.Salary);
            Assert.Equal(model.TypeId, result.TypeId);
            Assert.Equal(setup.firstService.Id, result.Id);
            Assert.Equal(setup.firstService.PersonId, result.PersonId);
        }
Beispiel #2
0
        public async Task PutService_Created_Success_Result()
        {
            var types = await CreateDefaultTypesAsync();

            var setup = await SetupAuthenticationAsync();

            var model = new EventServiceModel
            {
                Id       = -1,
                PersonId = -1,
                Profile  = Guid.NewGuid().ToString(),
                Salary   = 1000,
                TypeId   = types.djType.Id
            };

            var r = await _Client.PutAsync("api/service", model.ToStringContent());

            Assert.Equal(HttpStatusCode.Created, r.StatusCode);

            var result  = JsonConvert.DeserializeObject <EventServiceModel>(await r.Content.ReadAsStringAsync());
            var dbEntry = await CreateDataContext().EventService.FirstOrDefaultAsync(x => x.Profile == model.Profile);

            Assert.NotNull(dbEntry);
            Assert.Equal(dbEntry.Id, result.Id);

            Assert.NotNull(result);
            Assert.Equal(model.Profile, result.Profile);
            Assert.Equal(model.Salary, result.Salary);
            Assert.Equal(model.TypeId, result.TypeId);
            Assert.Equal(setup.Person.Id, result.PersonId);
        }
Beispiel #3
0
        public async Task PostService_Success_Result()
        {
            var types = await CreateDefaultTypesAsync();

            var setup = await SetupServiceAsync();

            var model = new EventServiceModel
            {
                Id       = -1,
                PersonId = -1,
                Profile  = Guid.NewGuid().ToString(),
                Salary   = 10008,
                TypeId   = types.catererType.Id
            };

            var r = await _Client.PostAsync($"api/service/{setup.firstService.Id}", model.ToStringContent());

            r.EnsureSuccessStatusCode();

            var result = JsonConvert.DeserializeObject <EventServiceModel>(await r.Content.ReadAsStringAsync());

            Assert.NotNull(result);
            Assert.Equal(model.Profile, result.Profile);
            Assert.Equal(model.Salary, result.Salary);
            Assert.Equal(model.TypeId, result.TypeId);
            Assert.Equal(setup.firstService.Id, result.Id);
            Assert.Equal(setup.firstService.PersonId, result.PersonId);
        }