コード例 #1
0
        protected void OnCurrentCombatStatisticsChanged(object sender, CurrentCombatStatisticsChangedEventArgs args)
        {
            Guard.WhenArgument(args, nameof(CurrentCombatStatisticsChangedEventArgs)).IsNull().Throw();
            Guard.WhenArgument(args.CombatStatistics, nameof(ICombatStatistics)).IsNull().Throw();

            var finalizedCombatStatistics = this.combatStatisticsFinalizationStrategy.FinalizeCombatStatistics(args.CombatStatistics);
            var storedCombatStatistics    = this.combatStatisticsPersistentStorageStrategy.StoreCombatStatistics(finalizedCombatStatistics);
        }
コード例 #2
0
ファイル: Constructor_Should.cs プロジェクト: shakuu/Parser
        public void CreateCorrectEventArgsInstance_WhenParametersAreValid()
        {
            // Arrange
            var combatStatistics = new Mock <ICombatStatistics>();

            // Act
            var actualInstance = new CurrentCombatStatisticsChangedEventArgs(combatStatistics.Object);

            // Assert
            Assert.That(actualInstance, Is.Not.Null);
            Assert.That(actualInstance, Is.InstanceOf <EventArgs>());
        }
コード例 #3
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)));
        }
コード例 #4
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);
        }
コード例 #5
0
 internal new void OnCurrentCombatStatisticsChanged(object sender, CurrentCombatStatisticsChangedEventArgs args)
 {
     base.OnCurrentCombatStatisticsChanged(sender, args);
 }