public void LoadAndSaveWithBasketIdCookieTest1() { // Arrange var application = CreateDefaultApplication(); var repository = MockRepository.GenerateMock <IRepository>(); repository.Stub(x => x.GetApplication()).IgnoreArguments().Return(application); var httpContextWrapper = CreateRealHttpContextMock(); httpContextWrapper.RequestCookies.Add(new HttpCookie("StormSession") { Value = null }); httpContextWrapper.RequestCookies.Add(new HttpCookie("StormPersisted") { Value = null }); var ctx = new StormContext(repository, httpContextWrapper); StormContext.SetInstance(ctx); // Act StormContext.LoadCookie(); StormContext.BasketId = 4711; StormContext.SaveCookie(); StormContext.LoadCookie(); // Assert Assert.AreEqual(4711, StormContext.BasketId); }
public void LoadCookieInvalidCookieWithRefreshTest1() { // Arrange var application = CreateDefaultApplication(); var repository = MockRepository.GenerateMock <IRepository>(); repository.Stub(x => x.GetApplication()).IgnoreArguments().Return(application); var httpContextWrapper = CreateEmptyHttpContextMock(); httpContextWrapper.RequestCookies.Add(new HttpCookie("StormSession") { Value = null }); httpContextWrapper.RequestCookies.Add(new HttpCookie("StormPersisted") { Value = "LoginName=!null!&AccountId=!null!&CustomerId=!null!&CompanyId=!null!&DivisionId=!null!&BasketId=!null!&CurrencyId=5&CultureCode=da-DK&SalesAreaId=3&ShowPricesIncVat=!null!&IsPrivate=True&ReferId=!null!&ReferUrl=!null!&RememberMe=True" }); var ctx = new StormContext(repository, httpContextWrapper); StormContext.SetInstance(ctx); // Act StormContext.LoadCookie(); // Assert Assert.AreEqual("sv-SE", StormContext.CultureCode); Assert.AreEqual(1, StormContext.CurrencyId); Assert.AreEqual(1, StormContext.SalesAreaId); }
public void SaveCookieTest1() { // Arrange var application = CreateDefaultApplication(); var repository = MockRepository.GenerateMock <IRepository>(); repository.Stub(x => x.GetApplication()).IgnoreArguments().Return(application); var httpContextWrapper = CreateEmptyHttpContextMock(); httpContextWrapper.RequestCookies.Add(new HttpCookie("StormSession") { Value = null }); httpContextWrapper.RequestCookies.Add(new HttpCookie("StormPersisted") { Value = null }); var ctx = new StormContext(repository, httpContextWrapper); StormContext.SetInstance(ctx); // Act StormContext.LoadCookie(); StormContext.BasketId = 1; StormContext.CustomerId = 123456; StormContext.LoginName = "*****@*****.**"; StormContext.SaveCookie(); // Assert Assert.AreEqual("[email protected]&AccountId=!null!&CustomerId=123456&CompanyId=!null!&DivisionId=!null!&BasketId=1&CurrencyId=1&CultureCode=sv-SE&SalesAreaId=1&ShowPricesIncVat=!null!&IsPrivate=True&ReferId=!null!&RememberMe=True", httpContextWrapper.ResponseCookies["StormPersisted"].Value); }
public void LoadCookieEmptyCookieTest1() { // Arrange var application = CreateDefaultApplication(); var repository = MockRepository.GenerateMock <IRepository>(); repository.Stub(x => x.GetApplication()).IgnoreArguments().Return(application); var httpContextWrapper = CreateEmptyHttpContextMock(); httpContextWrapper.RequestCookies.Add(new HttpCookie("StormSession") { Value = null }); httpContextWrapper.RequestCookies.Add(new HttpCookie("StormPersisted") { Value = null }); var ctx = new StormContext(repository, httpContextWrapper); StormContext.SetInstance(ctx); // Act StormContext.LoadCookie(); // Assert Assert.AreEqual("sv-SE", StormContext.CultureCode); Assert.AreEqual(1, StormContext.CurrencyId); Assert.AreEqual(1, StormContext.SalesAreaId); }