コード例 #1
0
        public void When_Inner_UseCase_Expect_65()
        {
            // arrange
            var input = new TestInput
            {
                a = 10,
                b = 25
            };
            var addTask     = new AddStep();
            var plusTenTask = new PlusTenStep();

            var presenter    = new PropertyPresenter <TestResult, ErrorOutput>();
            var innerUseCase = new AddTwoNumbersThenAddTen(addTask, plusTenTask);
            var sut          = new AddTwoNumbersTwiceOnceUsingUseCase(innerUseCase, addTask, plusTenTask);

            // act
            sut.Execute(input, presenter);
            // assert
            var expected = new TestResult
            {
                Result = 65
            };

            presenter.SuccessContent.Should().BeEquivalentTo(expected);
        }
コード例 #2
0
        public void When_Using_DI_Expect_135()
        {
            // arrange
            var input = new TestInput
            {
                a = 10,
                b = 25
            };
            var myRepository  = new MathOperations();
            var addTask       = new AddStep();
            var addWithDiTask = new AddStepWithRepository(myRepository);

            var presenter = new PropertyPresenter <TestResult, ErrorOutput>();

            var sut = new AddTwoNumbersUsingDiInjectedRepository(addTask, addWithDiTask);

            // act
            sut.Execute(input, presenter);
            // assert
            var expected = new TestResult
            {
                Result = 135
            };

            presenter.SuccessContent.Should().BeEquivalentTo(expected);
        }
コード例 #3
0
ファイル: ActionStepHandler.cs プロジェクト: Burakovivan/VSG
        public ActionStepHandler(ElementSelector elementSelector, int actionType)
        {
            TextBoxDict = new Dictionary <string, TextBox>();
            var actionTypeValue = (EventAction)actionType;

            switch (actionTypeValue)
            {
            case EventAction.Add:
                ElementStep = new AddStep(elementSelector);
                break;

            case EventAction.Remove:
                ElementStep = new RemoveStep(elementSelector);
                break;

            case EventAction.Move:
                if (elementSelector.ElementType == ElementType.Event)
                {
                    ElementStep = new MoveStep(elementSelector);
                }
                break;

            case EventAction.SetEffect:
                ElementStep = new SetEffectStep(elementSelector);
                break;
            }
        }
コード例 #4
0
ファイル: AddStepTests.cs プロジェクト: davidov541/SAMI
        public void AddStepCloneTest()
        {
            AddStep originalStep = new AddStep();
            AddStep clonedStep   = originalStep.Clone() as AddStep;

            Assert.IsNotNull(clonedStep);
            Assert.AreEqual(originalStep.IsStepDone, clonedStep.IsStepDone);
            Assert.AreEqual(originalStep.MessageToUser, clonedStep.MessageToUser);
            Assert.AreEqual(originalStep.Name, clonedStep.Name);
            Assert.AreEqual(originalStep.NextGrammarNeeded, clonedStep.NextGrammarNeeded);
            Assert.AreEqual(originalStep.ShouldCancel, clonedStep.ShouldCancel);
        }
コード例 #5
0
ファイル: AddStepTests.cs プロジェクト: davidov541/SAMI
        public void AddStepDoStepInvalidUserInputTest()
        {
            AddStep step = new AddStep();
            Mock <IBartenderController> bartender = new Mock <IBartenderController>(MockBehavior.Strict);

            bartender.Setup(s => s.IsValid).Returns(true);
            step.DoStep(new Dialog(new Dictionary <String, String>(), "Test Phrase"), bartender.Object, new Ingredient("TestIngredient", 1, IngredientUnit.Part, "Test Ingredient"));
            Assert.AreEqual("Add Test Ingredient to the glass and tell me when you are done.", step.MessageToUser);
            Assert.AreEqual(false, step.IsStepDone);
            Assert.AreEqual("Add", step.Name);
            Assert.AreEqual(BartenderApp.ConfirmationRuleName, step.NextGrammarNeeded);
            Assert.AreEqual(false, step.ShouldCancel);
        }
コード例 #6
0
ファイル: AddStepTests.cs プロジェクト: davidov541/SAMI
        public void AddStepDoStepFalseAnswerTest()
        {
            AddStep step = new AddStep();
            Mock <IBartenderController> bartender = new Mock <IBartenderController>(MockBehavior.Strict);

            bartender.Setup(s => s.IsValid).Returns(true);
            Dictionary <String, String> input = new Dictionary <string, string>
            {
                { "answer", "false" },
            };

            step.DoStep(new Dialog(input, "Test Phrase"), bartender.Object, new Ingredient("TestIngredient", 1, IngredientUnit.Part, "Test Ingredient"));
            Assert.AreEqual(null, step.MessageToUser);
            Assert.AreEqual(true, step.IsStepDone);
            Assert.AreEqual("Add", step.Name);
            Assert.AreEqual(null, step.NextGrammarNeeded);
            Assert.AreEqual(true, step.ShouldCancel);
        }
コード例 #7
0
        public void When_Errors_Expect_Sum_Of_Two_Numbers_Plus_10()
        {
            // arrange
            var input = new TestInput
            {
                a = 10,
                b = 25
            };
            var addTask   = new AddStep();
            var errorTask = new AddTenErrorStep();
            var presenter = new PropertyPresenter <TestResult, ErrorOutput>();
            var sut       = new AddTwoNumbersThenAddTenThrowsError(addTask, errorTask);

            // act
            sut.Execute(input, presenter);
            // assert
            var expected = new ErrorOutput("Error in task\r\n");

            presenter.ErrorContent.Should().BeEquivalentTo(expected);
        }
コード例 #8
0
        public void When_No_Errors_Expect_Sum_Of_Two_Numbers_Plus_10()
        {
            // arrange
            var input = new TestInput
            {
                a = 10,
                b = 25
            };
            var addTask     = new AddStep();
            var plusTenTask = new PlusTenStep();
            var presenter   = new PropertyPresenter <TestResult, ErrorOutput>();
            var sut         = new AddTwoNumbersThenAddTen(addTask, plusTenTask);

            // act
            sut.Execute(input, presenter);
            // assert
            var expected = new TestResult
            {
                Result = 45
            };

            presenter.SuccessContent.Should().BeEquivalentTo(expected);
        }
        public CreateProfileViewModel(IScreen hostScreen, IFermentationControllerAPI api)
        {
            HostScreen = hostScreen;

            AllSteps = new ReactiveList <StepData> ();

            StepTiles = AllSteps.CreateDerivedCollection(x => new ProfileStepTileViewModel(x.StepId, x));

            var canAddStep = this.WhenAnyValue(x => x.StepDays, x => x.StepHours, x => x.StepMins)
                             .Select(x => x.Item1 > 0 || x.Item2 > 0 || x.Item3 > 0);

            AddStep = ReactiveCommand.Create(canAddStep);
            AddStep
            .ObserveOn(RxApp.MainThreadScheduler)
            .Select(x => new StepData(TemperatureConvert.ConvertToCelsius(StartingTemp),
                                      TemperatureConvert.ConvertToCelsius(EndingTemp),
                                      new TimeSpan(StepDays,
                                                   StepHours,
                                                   StepMins,
                                                   0),
                                      AllSteps.Count + 1,
                                      IsRampStep))
            .Subscribe(AllSteps.Add);

            var canCommit = this.WhenAnyValue(x => x.Name, x => x.AllSteps).Select(x => !string.IsNullOrWhiteSpace(x.Item1) && x.Item2.Count > 0);

            CommitProfile = ReactiveCommand.CreateAsyncTask(canCommit, (x, ct) => {
                //TODO: create the profile dto
                return(api.StoreProfile(Name, new byte[0]));
            }, RxApp.MainThreadScheduler);

            //on non-ramp steps the starting and ending temp are the same
            this.WhenAnyValue(x => x.StartingTemp, y => y.IsRampStep)
            .Where(x => !x.Item2)
            .Subscribe(x => EndingTemp = StartingTemp);
        }
コード例 #10
0
 public AddTwoNumbersThenAddTenThrowsError(AddStep addTask, AddTenErrorStep errorTask)
 {
     _errorTask = errorTask;
     _addTask   = addTask;
 }
コード例 #11
0
 public AddTwoNumbersTwiceOnceUsingUseCase(AddTwoNumbersThenAddTen useCase, AddStep addTask, PlusTenStep plusTenTask)
 {
     _useCase     = useCase;
     _addTask     = addTask;
     _plusTenTask = plusTenTask;
 }
コード例 #12
0
 public AddTwoNumbersUsingDiInjectedRepository(AddStep addTask, AddStepWithRepository addWithDiTask)
 {
     _addTask       = addTask;
     _addWithDiTask = addWithDiTask;
 }
コード例 #13
0
 public AddTwoNumbersThenAddTen(AddStep addTask, PlusTenStep plusTenTask)
 {
     _addTask     = addTask;
     _plusTenTask = plusTenTask;
 }