コード例 #1
0
        public async Task <TestingModel> CalculateSomethingRandom(int a, int b)
        {
            var value = RandomService.GenerateRandomValue(1, 1000);

            var sleep = await Sleepy.SleepForATime();

            if (!sleep)
            {
                FactoryException.Create();
            }

            var result = FactoryTestingModel.Empty();

            if (value < 250 && value > 0)
            {
                result = FactoryTestingModel.Create("Plus", value, a + b);
            }
            else if (value < 500 && value >= 250)
            {
                result = FactoryTestingModel.Create("Minus 10", value, a + b - 10);
            }
            else if (value < 750 && value >= 500)
            {
                result = FactoryTestingModel.Create("Plus 10", value, a + b + 10);
            }
            else if (value <= 1000 && value >= 750)
            {
                result = FactoryTestingModel.Create("Plus 20", value, a + b + 20);
            }
            else
            {
                FactoryException.Create("Out of range");
            }
            return(await AsyncExecutor.FromResult(result));
        }
コード例 #2
0
        public void CreateTest(string operationType, int randomValue, int value, FactoryTestingModel sut)
        {
            //act
            var expected = sut.Create(operationType, randomValue, value);

            //assert
            Assert.NotNull(expected);
            Assert.IsType <TestingModel>(expected);
            Assert.Equal(expected.OperationType, operationType);
            Assert.Equal(expected.RandomValue, randomValue.ToString());
            Assert.Equal(expected.Value, value);
        }
コード例 #3
0
        public void EmptyTest(FactoryTestingModel sut)
        {
            //act
            var expected = sut.Empty();

            //assert
            Assert.NotNull(expected);
            Assert.IsType <TestingModel>(expected);
            Assert.Null(expected.OperationType);
            Assert.Null(expected.RandomValue);
            Assert.Equal(0, expected.Value);
        }