Exemplo n.º 1
0
        public void GetProvincesWithoutResult()
        {
            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));
            dynamicMock.SetReturnValue("GetProvinces",new List<Province>());

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

            Assert.AreEqual(0,locationServices.GetProvinces().Count);
        }
Exemplo n.º 2
0
        public void TestDeleteCity()
        {
            List<City> cities = new List<City>();
            City city = new City { Name = "New York", DistrictId = 12 };
            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));
            dynamicMock.ExpectAndReturn("AddCity", 3,city);
            dynamicMock.SetReturnValue("GetCities", cities);
            dynamicMock.Expect("DeleteCityById", 2);

            LocationsManager mocklocationManager = (LocationsManager)dynamicMock.MockInstance;
            LocationServices locationService = new LocationServices(mocklocationManager);
            locationService.DeleteCity(2);
            Assert.AreEqual(3, locationService.AddCity(city));
            Assert.AreEqual(0, locationService.GetCities().Count);
        }
Exemplo n.º 3
0
        public void GetProvincesWhithResults()
        {
            List<Province> provinces = new List<Province>
                                           {
                                               new Province(),
                                               new Province(),
                                               new Province(),
                                               new Province()
                                           };

            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));
            dynamicMock.SetReturnValue("GetProvinces", provinces);

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

            Assert.AreEqual(4, locationServices.GetProvinces().Count);
        }
Exemplo n.º 4
0
        public void TestDeleteDistrictWithCityIn()
        {
            List<City> cities = _GetCities();

            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));
            dynamicMock.SetReturnValue("GetCities", cities);
            dynamicMock.Expect("DeleteDistrictById", 2);

            LocationsManager mocklocationManager = (LocationsManager)dynamicMock.MockInstance;
            LocationServices locationService = new LocationServices(mocklocationManager);
            Assert.AreEqual(false, locationService.DeleteDistrict(2));
        }
Exemplo n.º 5
0
        public void TestUpdateProvince()
        {
            Province provinceOne = new Province(2, "Pekin");
            List<Province> provinces = new List<Province> {provinceOne};

            DynamicMock mockLocationsManager = new DynamicMock(typeof(LocationsManager));
            mockLocationsManager.SetReturnValue("GetProvinces", provinces);
            mockLocationsManager.ExpectAndReturn("UpdateProvince", true, provinceOne);

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

            Assert.AreEqual("Pekin", locationService.GetProvinces()[0].Name);
            Assert.AreEqual(true, locationService.UpdateProvince(provinceOne));
        }
Exemplo n.º 6
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));
        }
Exemplo n.º 7
0
        public void TestUpdateCity()
        {
            City city = new City {Name = "Pekin", DistrictId = 12};
            List<City> cities = new List<City> {city};

            DynamicMock mockLocationsManager = new DynamicMock(typeof(LocationsManager));
            mockLocationsManager.ExpectAndReturn("AddCity", 3, city);
            mockLocationsManager.SetReturnValue("GetCities", cities);
            mockLocationsManager.ExpectAndReturn("UpdateCity", true, city);

            LocationsManager mocklocationManager = (LocationsManager)mockLocationsManager.MockInstance;
            LocationServices locationService = new LocationServices(mocklocationManager);
            Assert.AreEqual("Pekin", locationService.GetCities()[0].Name);
            Assert.AreEqual(true, locationService.UpdateCity(city));
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public void TestGetCitiesWhithResults()
        {
            List<City> cities = new List<City>
                                           {
                                               new City(),
                                               new City(),
                                               new City()
                                           };

            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));
            dynamicMock.SetReturnValue("GetCities", cities);

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

            Assert.AreEqual(3, locationServices.GetCities().Count);
        }
Exemplo n.º 10
0
        public void TestDeleteProvinceWithoutDistrictIn()
        {
            Province provinceOne = new Province(2, "Pekin");
            Province provinceTwo = new Province(8, "Qhinghua");

            List<District> districts = new List<District>
                                           {
                                               new District("Paris",provinceOne),
                                               new District("Pekin",provinceOne),
                                               new District("Pau",provinceOne)
                                           };

            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));
            dynamicMock.SetReturnValue("GetDistricts", districts);
            dynamicMock.Expect("DeleteProvinceById", 8);

            LocationsManager mocklocationManager = (LocationsManager)dynamicMock.MockInstance;
            LocationServices locationService = new LocationServices(mocklocationManager);
            Assert.AreEqual(true, locationService.DeleteProvince(provinceTwo));
        }