public void ThrowArgumentNullException_WhenStoredCombatStatisticsViewModelParameterIsNull() { // Arrange var storedCombatStatisticsEntityFrameworkRepository = new Mock <IEntityFrameworkRepository <StoredCombatStatistics> >(); var objectMapperProvider = new Mock <IObjectMapperProvider>(); var storedCombatStatisticsDataProvider = new StoredCombatStatisticsDataProvider(storedCombatStatisticsEntityFrameworkRepository.Object, objectMapperProvider.Object); StoredCombatStatisticsViewModel model = null; // Act & Assert Assert.That( () => storedCombatStatisticsDataProvider.CreateStoredCombatStatistics(model), Throws.InstanceOf <ArgumentNullException>().With.Message.Contains(nameof(StoredCombatStatisticsViewModel))); }
public void InvokeIObjectMapperProvider_MapStoredCombatStatisticsOnceWithCorrectParameter() { // Arrange var storedCombatStatisticsEntityFrameworkRepository = new Mock <IEntityFrameworkRepository <StoredCombatStatistics> >(); var objectMapperProvider = new Mock <IObjectMapperProvider>(); var storedCombatStatisticsDataProvider = new StoredCombatStatisticsDataProvider(storedCombatStatisticsEntityFrameworkRepository.Object, objectMapperProvider.Object); var model = new StoredCombatStatisticsViewModel(); // Act storedCombatStatisticsDataProvider.CreateStoredCombatStatistics(model); // Assert objectMapperProvider.Verify(p => p.Map <StoredCombatStatistics>(model), Times.Once); }
public void ReturnCorrectStoredCombatStatisticsViewModelInstance() { // Arrange var storedCombatStatisticsEntityFrameworkRepository = new Mock <IEntityFrameworkRepository <StoredCombatStatistics> >(); var objectMapperProvider = new Mock <IObjectMapperProvider>(); var storedCombatStatisticsDataProvider = new StoredCombatStatisticsDataProvider(storedCombatStatisticsEntityFrameworkRepository.Object, objectMapperProvider.Object); var model = new StoredCombatStatisticsViewModel(); var expectedReturnedStoredCombatStatisticsViewModelInstance = new StoredCombatStatisticsViewModel(); objectMapperProvider.Setup(p => p.Map <StoredCombatStatisticsViewModel>(It.IsAny <StoredCombatStatistics>())).Returns(expectedReturnedStoredCombatStatisticsViewModelInstance); // Act var actualReturnedStoredCombatStatisticsViewModelInstance = storedCombatStatisticsDataProvider.CreateStoredCombatStatistics(model); // Assert Assert.That(actualReturnedStoredCombatStatisticsViewModelInstance, Is.SameAs(expectedReturnedStoredCombatStatisticsViewModelInstance)); }
public void InvokeIEntityFrameworkRepository_CreateMethodOnceWithCorrectParameter() { // Arrange var storedCombatStatisticsEntityFrameworkRepository = new Mock <IEntityFrameworkRepository <StoredCombatStatistics> >(); var objectMapperProvider = new Mock <IObjectMapperProvider>(); var storedCombatStatisticsDataProvider = new StoredCombatStatisticsDataProvider(storedCombatStatisticsEntityFrameworkRepository.Object, objectMapperProvider.Object); var model = new StoredCombatStatisticsViewModel(); var storedCombatStatistics = new StoredCombatStatistics(); objectMapperProvider.Setup(p => p.Map <StoredCombatStatistics>(It.IsAny <StoredCombatStatisticsViewModel>())).Returns(storedCombatStatistics); // Act storedCombatStatisticsDataProvider.CreateStoredCombatStatistics(model); // Assert storedCombatStatisticsEntityFrameworkRepository.Verify(r => r.Create(storedCombatStatistics), Times.Once); }