Exemplo n.º 1
0
        public async Task Create_Appointment_OK()
        {
            using var factory = new AppointmentsControllerFactory();
            var fakeAppointment = factory.CreateFakeAppointment();

            await factory.Service.CreateAsync(fakeAppointment);

            (await factory.Context.Appointments.FirstAsync())
            .Should().BeEquivalentTo(fakeAppointment);
        }
Exemplo n.º 2
0
        public async Task Update_Appointment_OK()
        {
            using var factory = new AppointmentsControllerFactory();
            var A = factory.CreateFakeAppointment("A");

            (await factory.Service.CreateAsync(A))
            .Should().BeOfType <OkObjectResult>();

            A.Title = nameof(Update_Appointment_OK);

            (await factory.Service.UpdateAsync(A))
            .Should().BeOfType <OkObjectResult>();

            (await factory.Context.Appointments.FirstAsync())
            .Should().BeEquivalentTo(A);
        }
Exemplo n.º 3
0
        public async Task Create_InvalidAppointment_BadRequest()
        {
            using var factory = new AppointmentsControllerFactory();
            var fakeAppointment = factory.CreateFakeAppointment();

            fakeAppointment.Title = string.Empty;
            (await factory.Service.CreateAsync(fakeAppointment))
            .Should().BeOfType <BadRequestObjectResult>();

            fakeAppointment.Title = null;
            (await factory.Service.CreateAsync(fakeAppointment))
            .Should().BeOfType <BadRequestObjectResult>();

            (await factory.Service.CreateAsync(null))
            .Should().BeOfType <BadRequestObjectResult>();
        }