public void AddAppointment_WhenAppointmentAvailable_BooksAppointment()
        {
            var mockTokenGenerator = Substitute.For <IJwtTokenGenerator>();

            mockTokenGenerator.GetToken(Scope.PatientWrite).Returns("token");

            var mockRequestBuilder = Substitute.For <IAddAppointmentRequestBuilder>();

            mockRequestBuilder
            .Build(
                "1",
                "2",
                "1",
                new DateTime(2020, 02, 05, 10, 10, 00),
                new DateTime(2020, 02, 05, 10, 20, 00))
            .Returns(new AddAppointmentRequest());

            var mockClient = Substitute.For <IAddAppointmentHttpClientWrapper>();

            mockClient.PostAsync(Arg.Any <string>()).Returns(_files["success"]);

            var mockDeserializer = Substitute.For <IAddAppointmentResponseDeserializer>();

            mockDeserializer.Deserialize(_files["success"]).Returns(JsonConvert.DeserializeObject <AddAppointmentResponse>(_files["success"]));

            var sut = new AddAppointmentClient(mockTokenGenerator, mockRequestBuilder, mockClient, mockDeserializer);

            var result = sut.AddAppointment("1",
                                            "2",
                                            "1",
                                            new DateTime(2020, 02, 05, 10, 10, 00),
                                            new DateTime(2020, 02, 05, 10, 20, 00));

            result.Should().NotBeNull();
            result.Result.description.Should()
            .BeEquivalentTo("A test appointment booked through Interactive Swagger API");
        }
        public void AddAppointment_WhenAppointmentNotAvailable_ReturnsOutcome()
        {
            var mockTokenGenerator = Substitute.For <IJwtTokenGenerator>();

            mockTokenGenerator.GetToken(Scope.PatientWrite).Returns("token");

            var mockRequestBuilder = Substitute.For <IAddAppointmentRequestBuilder>();

            mockRequestBuilder
            .Build(
                "1",
                "2",
                "1",
                new DateTime(2020, 02, 05, 10, 10, 00),
                new DateTime(2020, 02, 05, 10, 20, 00))
            .Returns(new AddAppointmentRequest());

            var mockClient = Substitute.For <IAddAppointmentHttpClientWrapper>();

            mockClient.PostAsync(Arg.Any <string>()).Returns(_files["fail"]);

            var mockDeserializer = Substitute.For <IAddAppointmentResponseDeserializer>();

            mockDeserializer.Deserialize(_files["fail"]).Returns(JsonConvert.DeserializeObject <AddAppointmentResponse>(_files["fail"]));

            var sut = new AddAppointmentClient(mockTokenGenerator, mockRequestBuilder, mockClient, mockDeserializer);

            var result = sut.AddAppointment("1",
                                            "2",
                                            "1",
                                            new DateTime(2020, 02, 05, 10, 10, 00),
                                            new DateTime(2020, 02, 05, 10, 20, 00));

            result.Should().NotBeNull();
            result.Result.resourceType.Should().BeEquivalentTo("OperationOutcome");
        }