Exemplo n.º 1
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);
        }