public void Test_Add_And_Get_Item_From_Cache_Expired_Pass() { //Arrange Customer customer = new Customer { CustomerId = new Random(DateTime.Now.Millisecond).Next(), FirstName = "Mary", LastName = "Doe", Address = "555 Main St.", City = "Austin", State = "TX", Zip = "73301", EmailAddress = "mary@internal" }; string customerId = customer.CustomerId.ToString(); //Act (add and remove from cache, then attempt to retrieve) _cache.Add(customerId, customer, 1); Thread.Sleep(1000); var cachedCustomer = _cache.Get<Customer>(customerId); //Assert - should be null as it's expired Assert.IsNull(cachedCustomer); }
public void Test_Add_And_Item_Exists_In_Cache_Pass() { //Arrange Customer customer = new Customer { CustomerId = new Random(DateTime.Now.Millisecond).Next(), FirstName = "Mary", LastName = "Doe", Address = "555 Main St.", City = "Austin", State = "TX", Zip = "73301", EmailAddress = "mary@internal" }; string customerId = customer.CustomerId.ToString(); //Act (add and remove from cache, then attempt to retrieve) _cache.Add(customerId, customer, 5); //Assert Assert.IsTrue(_cache.Exists(customerId)); }
public void Test_Add_Item_To_Cache_Get_Item_From_Cache_Pass() { //Arrange Customer customer = new Customer { CustomerId = new Random(DateTime.Now.Millisecond).Next(), FirstName = "Mary", LastName = "Doe", Address = "555 Main St.", City = "Austin", State = "TX", Zip = "73301", EmailAddress = "mary@internal" }; string customerId = customer.CustomerId.ToString(); //Act _cache.Add(customerId, customer, 1); var cachedCustomer = _cache.Get<Customer>(customerId); //Assert Assert.AreSame(customer, cachedCustomer); }