Exemple #1
0
        public void ThrowArgumentNullException_WhenCurrentCombatStatisticsChangedEventArgsParameterIsNull()
        {
            // Arrange
            var commandResolutionHandler                  = new Mock <ICommandResolutionHandler>();
            var combatStatisticsContainer                 = new Mock <ICombatStatisticsContainer>();
            var combatStatisticsFinalizationStrategy      = new Mock <ICombatStatisticsFinalizationStrategy>();
            var combatStatisticsPersistentStorageStrategy = new Mock <ICombatStatisticsPersistentStorageStrategy>();
            var liveCombatStatisticsCreationStrategy      = new Mock <ILiveCombatStatisticsCreationStrategy>();

            var logFileParserEngine = new MockLogFileParserEngine(commandResolutionHandler.Object, combatStatisticsContainer.Object, combatStatisticsFinalizationStrategy.Object, combatStatisticsPersistentStorageStrategy.Object, liveCombatStatisticsCreationStrategy.Object);

            CurrentCombatStatisticsChangedEventArgs args = null;

            // Act & Assert
            Assert.That(
                () => logFileParserEngine.OnCurrentCombatStatisticsChanged(null, args),
                Throws.InstanceOf <ArgumentNullException>().With.Message.Contains(nameof(CurrentCombatStatisticsChangedEventArgs)));
        }
Exemple #2
0
        public void InvokeICombatStatisticsFinalizationStrategy_FinalizeCombatStatisticsOnceWithCorrectParameter()
        {
            // Arrange
            var commandResolutionHandler                  = new Mock <ICommandResolutionHandler>();
            var combatStatisticsContainer                 = new Mock <ICombatStatisticsContainer>();
            var combatStatisticsFinalizationStrategy      = new Mock <ICombatStatisticsFinalizationStrategy>();
            var combatStatisticsPersistentStorageStrategy = new Mock <ICombatStatisticsPersistentStorageStrategy>();
            var liveCombatStatisticsCreationStrategy      = new Mock <ILiveCombatStatisticsCreationStrategy>();

            var logFileParserEngine = new MockLogFileParserEngine(commandResolutionHandler.Object, combatStatisticsContainer.Object, combatStatisticsFinalizationStrategy.Object, combatStatisticsPersistentStorageStrategy.Object, liveCombatStatisticsCreationStrategy.Object);

            var combatStatistics = new Mock <ICombatStatistics>();
            var args             = new CurrentCombatStatisticsChangedEventArgs(combatStatistics.Object);

            // Act
            logFileParserEngine.OnCurrentCombatStatisticsChanged(null, args);

            // Assert
            combatStatisticsFinalizationStrategy.Verify(s => s.FinalizeCombatStatistics(args.CombatStatistics), Times.Once);
        }
Exemple #3
0
        public void InvokeICommandResolutionHandler_ResolveCommandOnceWithCorrectParameters()
        {
            // Arrange
            var commandResolutionHandler                  = new Mock <ICommandResolutionHandler>();
            var combatStatisticsContainer                 = new Mock <ICombatStatisticsContainer>();
            var combatStatisticsFinalizationStrategy      = new Mock <ICombatStatisticsFinalizationStrategy>();
            var combatStatisticsPersistentStorageStrategy = new Mock <ICombatStatisticsPersistentStorageStrategy>();
            var liveCombatStatisticsCreationStrategy      = new Mock <ILiveCombatStatisticsCreationStrategy>();

            var command = new Mock <ICommand>();

            var logFileParserEngine = new MockLogFileParserEngine(commandResolutionHandler.Object, combatStatisticsContainer.Object, combatStatisticsFinalizationStrategy.Object, combatStatisticsPersistentStorageStrategy.Object, liveCombatStatisticsCreationStrategy.Object);

            logFileParserEngine.CombatStatisticsContainer = combatStatisticsContainer.Object;

            // Act
            logFileParserEngine.EnqueueCommand(command.Object);

            // Assert
            commandResolutionHandler.Verify(h => h.ResolveCommand(command.Object, combatStatisticsContainer.Object), Times.Once);
        }
        public void ReturnCorrectValue()
        {
            // Arrange
            var commandResolutionHandler                  = new Mock <ICommandResolutionHandler>();
            var combatStatisticsContainer                 = new Mock <ICombatStatisticsContainer>();
            var combatStatisticsFinalizationStrategy      = new Mock <ICombatStatisticsFinalizationStrategy>();
            var combatStatisticsPersistentStorageStrategy = new Mock <ICombatStatisticsPersistentStorageStrategy>();
            var liveCombatStatisticsCreationStrategy      = new Mock <ILiveCombatStatisticsCreationStrategy>();

            var command = new Mock <ICommand>();

            var logFileParserEngine = new MockLogFileParserEngine(commandResolutionHandler.Object, combatStatisticsContainer.Object, combatStatisticsFinalizationStrategy.Object, combatStatisticsPersistentStorageStrategy.Object, liveCombatStatisticsCreationStrategy.Object);

            logFileParserEngine.CombatStatisticsContainer = combatStatisticsContainer.Object;

            var expectedResult = combatStatisticsContainer.Object;

            // Act
            var actualResult = logFileParserEngine.GetLiveCombatStatistics();

            // Assert
            Assert.That(actualResult, Is.SameAs(expectedResult));
        }