Пример #1
0
        // Change so that each service is created on start and new service not created for each request
        public IndexedLocationResponse ReadIndexedLocation()
        {
            var request = new IndexedLocationRequest()
            {
            };
            var response = new IndexedLocationService.IndexedLocation().ReadIndexedLocation();

            return(response);
        }
Пример #2
0
        public IndexedLocationResponse UpdateIndexedLocation(string indexedLocation)
        {
            var request = new IndexedLocationRequest()
            {
                IndexedLocation = indexedLocation
            };
            var response = new IndexedLocationService.IndexedLocation().UpdateIndexedLocation(request);

            return(response);
        }
        public void IndexedLocationIsNullOrEmptyIndexReturnsError()
        {
            var request = new IndexedLocationRequest()
            {
                IndexedLocation = ""
            };
            var response = new MongoIndexedLocation().Insert(request, MockMongoDatabase.Object);

            Assert.IsFalse(String.IsNullOrEmpty(response.Error));
        }
        public void IndexLocationIsValidReturnsLocationAndNoError()
        {
            var location = "TestLocation";
            var request  = new IndexedLocationRequest()
            {
                IndexedLocation = location
            };
            var response = new MongoIndexedLocation().Insert(request, MockMongoDatabase.Object);

            Assert.AreEqual(location, response.IndexedLocation);
            Assert.IsTrue(String.IsNullOrEmpty(response.Error));
        }
        public void NoIndexedLocationInsertsCreatesNewIndexedLocation()
        {
            var indexedLocation = "indexedLocation";
            var service         = new IndexedLocation("TestMosaicDatabase");
            var request         = new IndexedLocationRequest()
            {
                IndexedLocation = indexedLocation
            };

            service.UpdateIndexedLocation(request);

            var response = service.ReadIndexedLocation();

            Assert.AreEqual(indexedLocation, response.IndexedLocation);
        }
Пример #6
0
        // Once messaging service in place can replace bool type to request and response
        // Check that only one Indexed location once insert complete
        public IndexedLocationResponse Insert(IndexedLocationRequest request, IMongoDatabase db)
        {
            var collection = db.GetCollection <IndexedLocationRequest>("IndexedLocation");

            if (String.IsNullOrEmpty(request.IndexedLocation))
            {
                return(new IndexedLocationResponse()
                {
                    IndexedLocation = request.IndexedLocation, Error = "Location cannot be empty"
                });
            }
            var result = collection.ReplaceOne(x => x.IndexedLocation != null, request, new UpdateOptions {
                IsUpsert = true
            });

            return(new IndexedLocationResponse()
            {
                IndexedLocation = request.IndexedLocation
            });
        }
        public void OneIndexedLocationInsertReplacesIndexedLocation()
        {
            var oldIndexedLocation = "oldIndexedLocation";
            var newIndexedLocation = "newIndexedLocation";
            var service            = new IndexedLocation("TestMosaicDatabase");

            var request1 = new IndexedLocationRequest()
            {
                IndexedLocation = oldIndexedLocation
            };

            service.UpdateIndexedLocation(request1);

            var request2 = new IndexedLocationRequest()
            {
                IndexedLocation = newIndexedLocation
            };

            service.UpdateIndexedLocation(request2);

            var response = service.ReadIndexedLocation();

            Assert.AreEqual(newIndexedLocation, response.IndexedLocation);
        }
Пример #8
0
 public IndexedLocationResponse UpdateIndexedLocation(IndexedLocationRequest request)
 {
     return(new MongoIndexedLocation().Insert(request, database));
 }