Esempio n. 1
0
        public void TestGetDistrictsWithoutResult()
        {
            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));

            dynamicMock.SetReturnValue("GetDistricts", new List <District>());

            LocationsManager locationsManager = (LocationsManager)dynamicMock.MockInstance;
            LocationServices locationServices = new LocationServices(locationsManager);

            Assert.AreEqual(0, locationServices.GetDistricts().Count);
        }
Esempio n. 2
0
        public void TestGetDistrictsWhithResults()
        {
            List <District> districts = new List <District>
            {
                new District(),
                new District(),
                new District()
            };

            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));

            dynamicMock.SetReturnValue("GetDistricts", districts);

            LocationsManager locationsManager = (LocationsManager)dynamicMock.MockInstance;
            LocationServices locationServices = new LocationServices(locationsManager);

            Assert.AreEqual(3, locationServices.GetDistricts().Count);
        }
Esempio n. 3
0
        public void TestUpdateDistrict()
        {
            Province        provinceOne = new Province(2, "Pekin");
            District        district    = new District("Pekin", provinceOne);
            List <District> districts   = new List <District> {
                district
            };


            DynamicMock mockLocationsManager = new DynamicMock(typeof(LocationsManager));

            mockLocationsManager.SetReturnValue("GetDistricts", districts);
            mockLocationsManager.ExpectAndReturn("UpdateDistrict", true, district);


            LocationsManager mocklocationManager = (LocationsManager)mockLocationsManager.MockInstance;
            LocationServices locationService     = new LocationServices(mocklocationManager);

            Assert.AreEqual("Pekin", locationService.GetDistricts()[0].Name);
            Assert.AreEqual(true, locationService.UpdateDistrict(district));
        }