public void IPAddressRepository_SaveChanges_IPAddressesAreWrittenIntoFile() { IPAddressRepository repository = new IPAddressRepository("EmptyConfiguration.xml"); PartOfIPAddress expected = new PartOfIPAddress("Cam1", "x.x.x.139"); repository.Add(expected); repository.SaveChanges(); IPAddressRepository repository2 = new IPAddressRepository("EmptyConfiguration.xml"); PartOfIPAddress actual = repository2.GetById("Cam1"); Assert.AreEqual(expected.ReferenceId, actual.ReferenceId); Assert.AreEqual(expected.Part, actual.Part); Assert.AreEqual(expected, actual); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { // Active when publish web string VisitorsIPAddr = string.Empty; if (HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] != null) { VisitorsIPAddr = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(); } else if (HttpContext.Current.Request.UserHostAddress.Length != 0) { VisitorsIPAddr = HttpContext.Current.Request.UserHostAddress; var addIpAddress = new IPAddressRepository().AddIpAddress(VisitorsIPAddr); } }
public void IPAddressRepository_IPAddressesAreLoaded() { IPAddressRepository repository = new IPAddressRepository(ConfigBuilderRepositoryFilePath); var ipAddressList = repository.GetAll(); Assert.IsTrue(ipAddressList.Count > 0); }