コード例 #1
0
        public void GetAllRegionTestOk()
        {
            List <Region> listOfRegions = new List <Region>();
            Region        region        = new Region
            {
                Id   = Guid.NewGuid(),
                Name = Region.RegionName.Región_Centro_Sur
            };

            listOfRegions.Add(region);
            Region region2 = new Region
            {
                Id   = Guid.NewGuid(),
                Name = Region.RegionName.Región_Corredor_Pajaros_Pintados
            };

            listOfRegions.Add(region2);


            var regionMock = new Mock <IRepository <Region> >(MockBehavior.Strict);

            regionMock.Setup(m => m.GetAll()).Returns(listOfRegions);

            RegionManagement regionLogic = new RegionManagement(regionMock.Object);

            List <Region> result = regionLogic.GetAllRegions();

            regionMock.VerifyAll();
            CollectionAssert.AreEqual(listOfRegions, result);
        }
コード例 #2
0
        public void GetClientExceptionGettingAllRegionTest()
        {
            List <Region> listOfRegions = new List <Region>();
            Region        region        = new Region
            {
                Id   = Guid.NewGuid(),
                Name = Region.RegionName.Región_Centro_Sur
            };

            listOfRegions.Add(region);
            Region region2 = new Region
            {
                Id   = Guid.NewGuid(),
                Name = Region.RegionName.Región_Corredor_Pajaros_Pintados
            };

            listOfRegions.Add(region2);


            var regionMock = new Mock <IRepository <Region> >(MockBehavior.Strict);

            regionMock.Setup(m => m.GetAll()).Throws(new ClientException());

            RegionManagement regionLogic = new RegionManagement(regionMock.Object);

            List <Region> result = regionLogic.GetAllRegions();
        }