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 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.º 3
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));
        }