public async Task UpdateServiceProviderSlot_Forbidden_2()
        {
            var types = await CreateDefaultTypesAsync();

            var setup = await SetupEventAsync();

            var sps = new ServiceSlot
            {
                EventId = setup.secondEvent.Id,
                TypeId  = types.djType.Id
            };

            _Context.ServiceSlots.Add(sps);
            await _Context.SaveChangesAsync();

            var newSps = new ServiceSlot
            {
                Id      = -1,
                EventId = -1,
                TypeId  = types.catererType.Id
            };


            var r = await _Client.PostAsync($"api/event/{sps.EventId}/sps/{sps.Id}", newSps.ToStringContent());

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

            var error = JsonConvert.DeserializeObject <ExceptionDTO>(await r.Content.ReadAsStringAsync());

            Assert.Equal(Guid.Parse(EventErrorCodes.NO_UPDATE_PERMISSIONS), error.ErrorCode);
        }
        public async Task UpdateServiceProviderSlot_NotFound_3_Type()
        {
            var types = await CreateDefaultTypesAsync();

            var setup = await SetupEventAsync();

            var sps = new ServiceSlot
            {
                EventId = setup.firstEvent.Id,
                TypeId  = types.djType.Id
            };

            _Context.ServiceSlots.Add(sps);
            await _Context.SaveChangesAsync();

            var newSps = new ServiceSlot
            {
                Id      = -1,
                EventId = -1,
                TypeId  = 999
            };


            var r = await _Client.PostAsync($"api/event/{sps.EventId}/sps/{sps.Id}", newSps.ToStringContent());

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

            var error = JsonConvert.DeserializeObject <ExceptionDTO>(await r.Content.ReadAsStringAsync());

            Assert.Equal(Guid.Parse(ServiceTypeErrorCodes.SERVICE_TYPE_NOT_FOUND), error.ErrorCode);
        }
        public async Task UpdateServiceProviderSlot_Success()
        {
            var types = await CreateDefaultTypesAsync();

            var setup = await SetupEventAsync();

            var sps = new ServiceSlot
            {
                EventId = setup.firstEvent.Id,
                TypeId  = types.djType.Id
            };

            _Context.ServiceSlots.Add(sps);
            await _Context.SaveChangesAsync();

            var newSps = new ServiceSlot
            {
                Id      = -1,
                EventId = -1,
                TypeId  = types.catererType.Id
            };

            var r = await _Client.PostAsync($"api/event/{sps.EventId}/sps/{sps.Id}", newSps.ToStringContent());

            r.EnsureSuccessStatusCode();
        }
        public async Task UpdateServiceProviderSlot_422_1_StartBeforeEnd()
        {
            var types = await CreateDefaultTypesAsync();

            var setup = await SetupEventAsync();

            var sps = new ServiceSlot
            {
                EventId = setup.firstEvent.Id,
                TypeId  = types.djType.Id
            };

            _Context.ServiceSlots.Add(sps);
            await _Context.SaveChangesAsync();

            var newSps = new ServiceSlot
            {
                Id      = -1,
                EventId = -1,
                TypeId  = types.catererType.Id,
                End     = DateTime.UtcNow,
                Start   = DateTime.UtcNow.AddDays(1)
            };


            var r = await _Client.PostAsync($"api/event/{sps.EventId}/sps/{sps.Id}", newSps.ToStringContent());

            Assert.Equal((HttpStatusCode)422, r.StatusCode);
            var error = JsonConvert.DeserializeObject <ExceptionDTO>(await r.Content.ReadAsStringAsync());

            Assert.Equal(Guid.Parse(ServiceSlotErrorCodes.START_MUSE_BE_BEFORE_END), error.ErrorCode);
        }
Exemplo n.º 5
0
        public async Task AddServiceSlot_NotFound_3_Type()
        {
            var setup = await SetupEventAsync();

            var sps = new ServiceSlot
            {
                EventId = -1,
                TypeId  = 999
            };

            var r = await _Client.PutAsync($"api/event/{setup.firstEvent.Id}/sps", sps.ToStringContent());

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

            var error = JsonConvert.DeserializeObject <ExceptionDTO>(await r.Content.ReadAsStringAsync());

            Assert.Equal(Guid.Parse(ServiceTypeErrorCodes.SERVICE_TYPE_NOT_FOUND), error.ErrorCode);
        }
Exemplo n.º 6
0
        public async Task AddServiceSlot_NotFound_1_Event()
        {
            var setup = await SetupEventAsync();

            var sps = new ServiceSlot
            {
                EventId = setup.firstEvent.Id,
                TypeId  = 1
            };

            var r = await _Client.PutAsync("api/event/999/sps", sps.ToStringContent());

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

            var answer = JsonConvert.DeserializeObject <ExceptionDTO>(await r.Content.ReadAsStringAsync());

            Assert.Equal(Guid.Parse(EventErrorCodes.EVENT_NOT_FOUND), answer.ErrorCode);
        }
Exemplo n.º 7
0
        public async Task AddServiceSlot_Success()
        {
            var types = await CreateDefaultTypesAsync();

            var setup = await SetupEventAsync();

            var sps = new ServiceSlot
            {
                EventId = -1,
                TypeId  = types.djType.Id
            };

            var r = await _Client.PutAsync($"api/event/{setup.firstEvent.Id}/sps", sps.ToStringContent());

            r.EnsureSuccessStatusCode();

            Assert.Equal(HttpStatusCode.Created, r.StatusCode);
        }
Exemplo n.º 8
0
        public async Task AddServiceSlot_422_StartNoSqlDate()
        {
            var types = await CreateDefaultTypesAsync();

            var setup = await SetupEventAsync();

            var slot = new ServiceSlot
            {
                Start  = new DateTime(1, 1, 1),
                TypeId = types.djType.Id
            };

            var r = await _Client.PutAsync($"api/event/{setup.firstEvent.Id}/sps", slot.ToStringContent());

            Assert.Equal((HttpStatusCode)422, r.StatusCode);
            var error = JsonConvert.DeserializeObject <ExceptionDTO>(await r.Content.ReadAsStringAsync());

            Assert.Equal(Guid.Parse(ServiceSlotErrorCodes.START_DATE_INVALID), error.ErrorCode);
        }
Exemplo n.º 9
0
        public async Task AddServiceSlot_Forbidden_2()
        {
            var types = await CreateDefaultTypesAsync();

            var setup = await SetupEventAsync();

            var sps = new ServiceSlot
            {
                EventId = -1,
                TypeId  = types.djType.Id
            };

            var r = await _Client.PutAsync($"api/event/{setup.secondEvent.Id}/sps", sps.ToStringContent());

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

            var error = JsonConvert.DeserializeObject <ExceptionDTO>(await r.Content.ReadAsStringAsync());

            Assert.Equal(Guid.Parse(EventErrorCodes.NO_UPDATE_PERMISSIONS), error.ErrorCode);
        }
        public async Task UpdateServiceProviderSlot_NotFound_4_Slot()
        {
            var setup = await SetupEventServiceSlotsAsync();

            var sps = new ServiceSlot
            {
                Id      = setup.firstSlot.Id,
                EventId = setup.firstEvent.Id,
                TypeId  = 1
            };

            var r = await _Client.PostAsync($"api/event/{setup.firstEvent.Id}/sps/999", sps.ToStringContent());

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

            var error = JsonConvert.DeserializeObject <ExceptionDTO>(await r.Content.ReadAsStringAsync());

            Assert.Equal(Guid.Parse(ServiceSlotErrorCodes.SERVICE_SLOT_NOT_FOUND), error.ErrorCode);
        }
        public async Task AddServiceSlot_422_EndNoSqlDate()
        {
            var setup = await SetupEventServiceSlotsAsync();

            var slot = new ServiceSlot
            {
                End    = new DateTime(1, 1, 1),
                TypeId = 1
            };

            var r = await _Client.PostAsync($"api/event/{setup.firstEvent.Id}/sps/{setup.firstSlot.Id}", slot.ToStringContent());

            Assert.Equal((HttpStatusCode)422, r.StatusCode);
            var error = JsonConvert.DeserializeObject <ExceptionDTO>(await r.Content.ReadAsStringAsync());

            Assert.Equal(Guid.Parse(ServiceSlotErrorCodes.END_DATE_INVALID), error.ErrorCode);
        }