public void When_there_is_cookie_Then_setValue_overwrites_cookie() { var existingCookie = new HttpCookie("cookie"); existingCookie.Value = "existing value"; existingCookie.Expires = DateTime.Now.AddDays(1); _httpResponse.Object.Cookies.Add(existingCookie); DateTime newExpirationDate = DateTime.Now.AddDays(2); _cookieContainer.SetValue("cookie", "new value", newExpirationDate); HttpCookie cookie = _httpResponse.Object.Cookies["cookie"]; Assert.That(cookie, Is.Not.Null, "cookie"); Assert.That(cookie.Value, Is.EqualTo("new value"), "cookie value"); Assert.That(cookie.Expires, Is.EqualTo(newExpirationDate), "cookie expiration date"); }