Ejemplo n.º 1
0
        public void WhenRemoteApiError()
        {
            //Arrange
            IIpstackApi        ipstackApi = new RemoteApiMock();
            IMapper            mapper     = AutomapperConfig.CreateConfiguration().CreateMapper();
            EntityFreamworkMoq geolocationsRepositories = new EntityFreamworkMoq();
            string             ip = " ";

            //Act
            var logic = new GeolocationLogic(ipstackApi, mapper, geolocationsRepositories);
            var res   = logic.GetValue(ip);

            //Assert
            Assert.IsFalse(res.Succesful);
            geolocationsRepositories.mockContext.Verify(m => m.SaveChanges(), Times.Never());
        }
Ejemplo n.º 2
0
        public void WhenNotExistInDataBase()
        {
            //Arrange
            IIpstackApi        ipstackApi = new RemoteApiMock();
            IMapper            mapper     = AutomapperConfig.CreateConfiguration().CreateMapper();
            EntityFreamworkMoq geolocationsRepositories = new EntityFreamworkMoq();
            string             ip = "0.0.0.0";

            //Act
            var logic = new GeolocationLogic(ipstackApi, mapper, geolocationsRepositories);
            var res   = logic.GetValue(ip);

            //Assert
            Assert.IsTrue(res.Succesful);
            Assert.AreEqual(res.Geolocation.Ip, ip);
            geolocationsRepositories.mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }