Ejemplo n.º 1
0
        public void InvokeIStoredCombatStatisticsDataProvider_CreateOnceWithCorrectParameter()
        {
            // Arrange
            var storedCombatStatisticsDataProvider = new Mock <IStoredCombatStatisticsDataProvider>();
            var businessTransactionFactory         = new Mock <IEntityFrameworkTransactionFactory>();
            var objectMapperProvider = new Mock <IObjectMapperProvider>();

            var businessTransaction = new Mock <IEntityFrameworkTransaction>();

            businessTransactionFactory.Setup(f => f.CreateEntityFrameworkTransaction()).Returns(businessTransaction.Object);

            var storedCombatStatisticsProjection = new StoredCombatStatisticsViewModel();

            objectMapperProvider.Setup(p => p.Map <StoredCombatStatisticsViewModel>(It.IsAny <IFinalizedCombatStatistics>())).Returns(storedCombatStatisticsProjection);

            var combatStatisticsPersistentStorageStrategy = new CombatStatisticsPersistentStorageStrategy(storedCombatStatisticsDataProvider.Object, businessTransactionFactory.Object, objectMapperProvider.Object);

            var finalizedCombatStatistics = new Mock <IFinalizedCombatStatistics>();

            // Act
            combatStatisticsPersistentStorageStrategy.StoreCombatStatistics(finalizedCombatStatistics.Object);

            // Assert
            storedCombatStatisticsDataProvider.Verify(r => r.CreateStoredCombatStatistics(storedCombatStatisticsProjection), Times.Once);
        }
Ejemplo n.º 2
0
        public void ReturnCorrectIFinalizedCombatStatisticsInstance()
        {
            // Arrange
            var storedCombatStatisticsDataProvider = new Mock <IStoredCombatStatisticsDataProvider>();
            var businessTransactionFactory         = new Mock <IEntityFrameworkTransactionFactory>();
            var objectMapperProvider = new Mock <IObjectMapperProvider>();

            var businessTransaction = new Mock <IEntityFrameworkTransaction>();

            businessTransactionFactory.Setup(f => f.CreateEntityFrameworkTransaction()).Returns(businessTransaction.Object);

            var storedCombatStatisticsProjection = new StoredCombatStatisticsViewModel();

            objectMapperProvider.Setup(p => p.Map <StoredCombatStatisticsViewModel>(It.IsAny <IFinalizedCombatStatistics>())).Returns(storedCombatStatisticsProjection);

            var combatStatisticsPersistentStorageStrategy = new CombatStatisticsPersistentStorageStrategy(storedCombatStatisticsDataProvider.Object, businessTransactionFactory.Object, objectMapperProvider.Object);

            var finalizedCombatStatistics = new Mock <IFinalizedCombatStatistics>();
            var expectedReturnedIFinalizedCombatStatisticsInstance = finalizedCombatStatistics.Object;
            // Act
            var actualReturnedIFinalizedCombatStatisticsInstance = combatStatisticsPersistentStorageStrategy.StoreCombatStatistics(finalizedCombatStatistics.Object);

            // Assert
            Assert.That(actualReturnedIFinalizedCombatStatisticsInstance, Is.SameAs(expectedReturnedIFinalizedCombatStatisticsInstance));
        }
Ejemplo n.º 3
0
        public void ThrowArgumentNullException_WhenIFinalizedCombatStatisticsParameterIsNull()
        {
            // Arrange
            var storedCombatStatisticsDataProvider = new Mock <IStoredCombatStatisticsDataProvider>();
            var businessTransactionFactory         = new Mock <IEntityFrameworkTransactionFactory>();
            var objectMapperProvider = new Mock <IObjectMapperProvider>();

            var combatStatisticsPersistentStorageStrategy = new CombatStatisticsPersistentStorageStrategy(storedCombatStatisticsDataProvider.Object, businessTransactionFactory.Object, objectMapperProvider.Object);

            IFinalizedCombatStatistics finalizedCombatStatistics = null;

            // Act & Assert
            Assert.That(
                () => combatStatisticsPersistentStorageStrategy.StoreCombatStatistics(finalizedCombatStatistics),
                Throws.InstanceOf <ArgumentNullException>().With.Message.Contains(nameof(IFinalizedCombatStatistics)));
        }
Ejemplo n.º 4
0
        public void InvokeIBusinessTransactionFactory_CreateBusinessTransactionOnce()
        {
            // Arrange
            var storedCombatStatisticsDataProvider = new Mock <IStoredCombatStatisticsDataProvider>();
            var businessTransactionFactory         = new Mock <IEntityFrameworkTransactionFactory>();
            var objectMapperProvider = new Mock <IObjectMapperProvider>();

            var businessTransaction = new Mock <IEntityFrameworkTransaction>();

            businessTransactionFactory.Setup(f => f.CreateEntityFrameworkTransaction()).Returns(businessTransaction.Object);

            var combatStatisticsPersistentStorageStrategy = new CombatStatisticsPersistentStorageStrategy(storedCombatStatisticsDataProvider.Object, businessTransactionFactory.Object, objectMapperProvider.Object);

            var finalizedCombatStatistics = new Mock <IFinalizedCombatStatistics>();

            // Act
            combatStatisticsPersistentStorageStrategy.StoreCombatStatistics(finalizedCombatStatistics.Object);

            // Assert
            businessTransactionFactory.Verify(f => f.CreateEntityFrameworkTransaction(), Times.Once);
        }