public void ToDashboardViewModel_WhenByteArrayCanBeDeserialized_AssertUnprotectWasCalledOnDataProtector() { IContentHelper sut = CreateSut(); byte[] byteArray = BuildDashboardViewModelAsByteArray(); sut.ToDashboardViewModel(byteArray); _dataProtectorMock.Verify(m => m.Unprotect(It.Is <byte[]>(value => value != null && value.Length > 0)), Times.Once); }
public void ToDashboardViewModel_WhenByteArrayCannotBeDeserialized_ReturnsNull() { IContentHelper sut = CreateSut(); byte[] byteArray = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString("D")); DashboardViewModel result = sut.ToDashboardViewModel(byteArray); Assert.IsNull(result); }
public void ToDashboardViewModel_WhenByteArrayCanBeDeserialized_AssertCreateProtectorWasCalledOnDataProtectionProviderWithDashboardProtection() { IContentHelper sut = CreateSut(); byte[] byteArray = BuildDashboardViewModelAsByteArray(); sut.ToDashboardViewModel(byteArray); _dataProtectionProviderMock.Verify(m => m.CreateProtector(It.Is <string>(value => string.CompareOrdinal(value, "DashboardProtection") == 0)), Times.Exactly(2)); }
public void ToDashboardViewModel_WhenByteArrayCannotBeDeserialized_AssertCreateProtectorWasCalledOnDataProtectionProviderWithDashboardProtection() { IContentHelper sut = CreateSut(); byte[] byteArray = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString("D")); sut.ToDashboardViewModel(byteArray); _dataProtectionProviderMock.Verify(m => m.CreateProtector(It.Is <string>(value => string.CompareOrdinal(value, "DashboardProtection") == 0)), Times.Once); }
public void ToDashboardViewModel_WhenByteArrayCannotBeDeserialized_AssertUnprotectWasCalledOnDataProtector() { IContentHelper sut = CreateSut(); byte[] byteArray = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString("D")); sut.ToDashboardViewModel(byteArray); _dataProtectorMock.Verify(m => m.Unprotect(It.Is <byte[]>(value => value != null && value.Length > 0)), Times.Once); }
public void ToDashboardViewModel_WhenByteArrayCanBeDeserializedAndCryptographicExceptionWasThrown_ReturnsNull() { CryptographicException exception = new CryptographicException(); IContentHelper sut = CreateSut(exception); byte[] byteArray = BuildDashboardViewModelAsByteArray(); DashboardViewModel result = sut.ToDashboardViewModel(byteArray); Assert.IsNull(result); }
public void ToDashboardViewModel_WhenByteArrayCanBeDeserialized_ReturnsDashboardViewModelWithDeserializedRedditAuthenticatedUser() { IContentHelper sut = CreateSut(); byte[] byteArray = BuildDashboardViewModelAsByteArray(); DashboardViewModel result = sut.ToDashboardViewModel(byteArray); Assert.IsNotNull(result); Assert.IsNotNull(result.RedditAuthenticatedUser); }
public void ToDashboardViewModel_WhenByteArrayCanBeDeserialized_ReturnsDashboardViewModelWithDeserializedRedditSubreddits() { IContentHelper sut = CreateSut(); byte[] byteArray = BuildDashboardViewModelAsByteArray(); DashboardViewModel result = sut.ToDashboardViewModel(byteArray); Assert.IsNotNull(result); Assert.IsNotNull(result.RedditSubreddits); Assert.AreEqual(1, result.RedditSubreddits.Count); }
public void ToDashboardViewModel_WhenByteArrayCanBeDeserialized_ReturnsDashboardViewModelWithDeserializedLatestInformationsWithImage() { IContentHelper sut = CreateSut(); byte[] byteArray = BuildDashboardViewModelAsByteArray(); DashboardViewModel result = sut.ToDashboardViewModel(byteArray); Assert.IsNotNull(result); Assert.IsNotNull(result.LatestInformationsWithImage); Assert.AreEqual(1, result.LatestInformationsWithImage.Count); }
public DashboardViewModel ToDashboardViewModel() { return(RestoreFromCookie <DashboardViewModel>(DashboardViewModel.CookieName, cookieValue => { string memoryCacheKey = _contentHelper.ToValue(cookieValue); if (string.IsNullOrWhiteSpace(memoryCacheKey)) { return null; } if (_memoryCache.TryGetValue(memoryCacheKey, out byte[] memoryCacheValue) == false) { return null; } return _contentHelper.ToDashboardViewModel(memoryCacheValue); }));
public void ToDashboardViewModel_WhenByteArrayIsNull_ThrowsArgumentNullException() { IContentHelper sut = CreateSut(); sut.ToDashboardViewModel(null); }