Exemple #1
0
        public void Assert(Happened repeatConstraint)
        {
            this.fakeObject.RemoveRule(this.RuleBeingBuilt);
            var asserter = this.asserterFactory.Invoke(this.Calls.Cast <IFakeObjectCall>());

            asserter.AssertWasCalled(this.Matcher.Matches, this.RuleBeingBuilt.ToString(), repeatConstraint.Matches, repeatConstraint.ToString());
        }
Exemple #2
0
 private void OnHealthChanged(int value)
 {
     if (value <= 0)
     {
         Happened?.Invoke();
     }
 }
Exemple #3
0
 public FileArgs(List <string> files, string project, Happened happened, Action <bool, string, EventArgs> callback)
 {
     Files    = files;
     Project  = project;
     Happened = happened;
     Callback = callback;
 }
Exemple #4
0
        /// <summary>
        /// 各行動の実処理関数
        /// </summary>
        /// <param name="states">現在のゲーム状態</param>
        /// <param name="happened">行動内容</param>
        /// <returns>行動結果を反映したゲーム状態</returns>
        public static GameStates ProcessActually(this GameStates states, Happened happened)
        {
            var result = happened.Predicate(states);

            result.AddHappenedLog(happened);
            return(result);
        }
Exemple #5
0
        public bool Never_should_return_instance_that_matches_one_or_above(int expectedRepeat, int repeat)
        {
            // Arrange
            var times = Happened.Times(expectedRepeat);

            // Act

            // Assert
            return(times.Matches(repeat));
        }
Exemple #6
0
        public void ConvertFromExpression_should_return_instance_that_has_correct_description()
        {
            // Arrange
            Expression <Func <int, bool> > repeatPredicate = repeat => repeat == 1;

            // Act
            var happened = Happened.ConvertFromExpression(repeatPredicate);

            // Assert
            Assert.That(happened.ToString(), Is.EqualTo("the number of times specified by the predicate 'repeat => (repeat = 1)'"));
        }
Exemple #7
0
        public bool ConvertFromExpression_should_return_instance_that_delegates_to_expression(int expected, int actual)
        {
            // Arrange
            Expression <Func <int, bool> > repeatPredicate = repeat => repeat == expected;

            // Act
            var happened = Happened.ConvertFromExpression(repeatPredicate);

            // Assert
            return(happened.Matches(actual));
        }
        public void Assert_happened_times_should_pass_when_call_has_happened_specified_number_of_times()
        {
            // Arrange
            this.foo.Bar();
            this.foo.Bar();
            this.foo.Bar();

            // Act

            // Assert
            A.CallTo(() => foo.Bar()).Assert(Happened.Times(3));
        }
Exemple #9
0
        public void Assert_with_void_call_should_assert_on_assertions_produced_by_factory()
        {
            // Arrange
            A.CallTo(() => this.ruleProducedByFactory.ToString()).Returns("call description");

            // Act
            this.builder.Assert(Happened.Times(99).Exactly);

            // Assert
            var repeatMatcher = A <Func <int, bool> > .That.Matches(x => x.Invoke(99) == true);

            Fake.Assert(this.asserter)
            .WasCalled(x => x.AssertWasCalled(A <Func <IFakeObjectCall, bool> > .Ignored, "call description", repeatMatcher, "exactly #99 times"));
        }
Exemple #10
0
        public void Assert_with_function_call_should_assert_on_assertions_produced_by_factory()
        {
            // Arrange
            A.CallTo(() => this.ruleProducedByFactory.ToString()).Returns("call description");

            // Act
            var returnConfig = new RuleBuilder.ReturnValueConfiguration <int>()
            {
                ParentConfiguration = this.builder
            };

            returnConfig.Assert(Happened.Times(99).Exactly);

            // Assert
            var repeatMatcher = A <Func <int, bool> > .That.Matches(x => x.Invoke(99) == true);

            A.CallTo(() => this.asserter.AssertWasCalled(A <Func <IFakeObjectCall, bool> > .Ignored, "call description", repeatMatcher, "exactly #99 times")).Assert(Happened.Once);
        }
Exemple #11
0
        private bool Do(Happened happened, bool isFolder, EventArgs args, ref string message)
        {
            switch (happened)
            {
            case Happened.Created:
            {
                return(isFolder
                        ? BrowseSystem.CreateProject((ProjectArgs)args, Control, ref message)
                        : BrowseSystem.CreateFile((FileArgs)args, Control, ref message));
            }

            case Happened.Deleted:
            {
                return(isFolder
                        ? TransactionDirectory.RemoveDirectory(Path.Combine(Control.FSWorker.WorkDirectory, ((ProjectArgs)args).Project))
                        : TransactionFile.DeleteFiles((FileArgs)args));
            }
            }
            return(false);
        }
        public void Asserting_on_calls()
        {
            var factory = A.Fake <IWidgetFactory>();

            // This would throw an exception since no call has been made.
            A.CallTo(() => factory.Create()).Assert(Happened.Once);
            A.CallTo(() => factory.Create()).Assert(Happened.Twice);
            A.CallTo(() => factory.Create()).Assert(Happened.Times(10));

            // This on the other hand would not throw.
            A.CallTo(() => factory.Create()).Assert(Happened.Never);

            // The number of times the call has been made can be restricted so that it must have happened
            // exactly the number of times specified
            A.CallTo(() => factory.Create()).Assert(Happened.Once.Exactly);
            A.CallTo(() => factory.Create()).Assert(Happened.Times(4).Exactly);

            // Then number of times can be specified so that it must not have happened more
            // than the specified number of times.
            A.CallTo(() => factory.Create()).Assert(Happened.Twice.OrLess);
            A.CallTo(() => factory.Create()).Assert(Happened.Times(5).OrLess);
        }
Exemple #13
0
 /// <summary>
 /// キャラクターのアクションを画面に反映する
 /// </summary>
 /// <param name="happened">アクション内容</param>
 /// <returns>描画処理成否</returns>
 public bool ReflectAction(Happened happened)
 {
     throw new NotImplementedException();
 }
 public void Assert(Happened repeatConstraint)
 {
     this.VoidConfiguration.Assert(repeatConstraint);
 }
Exemple #15
0
 /// <summary>
 /// 行動履歴に追加
 /// </summary>
 /// <param name="happened">履歴に追加される行動内容</param>
 public void AddHappenedLog(Happened happened)
 {
     _parameters.happenedLog.Add(happened);
 }
Exemple #16
0
 public ProjectArgs(string project, Happened happened, Action <bool, string, EventArgs> callback)
 {
     Project  = project;
     Happened = happened;
     Callback = callback;
 }
Exemple #17
0
 /// <summary>
 /// マップとアクションとアクション主語を受け取りアクション後のマップ状態を返す
 /// </summary>
 /// <param name="beforeMap">アクション実行前のマップ状態</param>
 /// <param name="action">アクション内容</param>
 /// <returns>アクション実施後マップオブジェクト</returns>
 public static Map UpdateMap(this Map beforeMap, Happened action)
 {
     throw new NotImplementedException();
 }