Exemplo n.º 1
0
        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)));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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);
        }