Пример #1
0
        public async Task ShouldReturnNullIfMissing()
        {
            var id         = 8;
            var clientMock = new ClientMock(_pact)
            {
                ConditionDescription = $"No subject with id '{id}' exists",
                Response             = new ProviderServiceResponse {
                    Status = 404
                }
            };
            var repo    = new PactConsumer1.ProducerRepository(clientMock);
            var product = await repo.GetProductById(id);

            Assert.Null(product);
        }
Пример #2
0
        public async Task ShouldReturnProductIfExists()
        {
            var id         = 1;
            var clientMock = new ClientMock(_pact)
            {
                ConditionDescription = $"Subject with id '{id}' exists",
                Response             = new ProviderServiceResponse {
                    Status  = 200,
                    Headers = new Dictionary <string, string> {
                        { "Content-Type", "application/json; charset=utf-8" }
                    },
                    Body = new ProductDto {
                        Id   = id,
                        Time = new DateTime(1984, 01, 01),
                        Type = "TypEtt"
                    }
                }
            };
            var repo    = new PactConsumer1.ProducerRepository(clientMock);
            var product = await repo.GetProductById(id);

            Assert.NotNull(product);
            Assert.Equal(id, product.Id);
        }