예제 #1
0
        public async Task BuilderResponseWhenRepositoryReturnsValidResponse()
        {
            var pharmacyInputModelMock = new PharmacyInputModel
            {
                Latitude  = 23.4,
                Longitude = -3.43
            };

            var pharmacyDataModelMock = new PharmacyDataModel
            {
                Name     = "Store1",
                Address  = "Address1",
                Distance = 23M
            };

            var pharmacyModelMock = new PharmacyModel
            {
                Name     = "Store1",
                Address  = "Address1",
                Distance = 23M
            };

            _pharmacyRepositoryMock.Setup(x => x.FindClosestPharmacyAsync(pharmacyInputModelMock.Latitude, pharmacyInputModelMock.Longitude)).ReturnsAsync(pharmacyDataModelMock);
            var pharmacyBuilder = new PharmacyBuilder(_pharmacyRepositoryMock.Object, _loggerMock.Object);

            Assert.True(pharmacyModelMock.Equals(await pharmacyBuilder.FindClosestAsync(pharmacyInputModelMock)));
        }
예제 #2
0
        public async Task BuilderResponseWhenRepositoryReturnsNull()
        {
            var pharmacyInputModelMock = new PharmacyInputModel
            {
                Latitude  = 23.4,
                Longitude = -3.43
            };

            _pharmacyRepositoryMock.Setup(x => x.FindClosestPharmacyAsync(pharmacyInputModelMock.Latitude, pharmacyInputModelMock.Longitude)).ReturnsAsync(() => null);
            var pharmacyBuilder = new PharmacyBuilder(_pharmacyRepositoryMock.Object, _loggerMock.Object);

            Assert.Null(await pharmacyBuilder.FindClosestAsync(pharmacyInputModelMock));
        }