Ejemplo n.º 1
0
        public async Task ShouldReturnRangeException()
        {
            //Arrange
            var start           = 101;
            var fizzBuzzService = new FizzBuzzService.Services.FizzBuzzService();
            var controller      = new FizzBuzzController(fizzBuzzService);

            //Act
            var result = await controller.GetAsync(start);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult));
        }
Ejemplo n.º 2
0
        public async Task ShouldReturnCorrectFizzBuzz()
        {
            //Arrange
            var start           = 0;
            var fizzBuzzService = new FizzBuzzService.Services.FizzBuzzService();
            var controller      = new FizzBuzzController(fizzBuzzService);

            //Act
            var result = await controller.GetAsync(start) as OkNegotiatedContentResult <List <string> >;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(result.Content.Count, 100);
        }
Ejemplo n.º 3
0
        public async Task ShouldCreateFile()
        {
            //Arrange
            DeleteContentDirectory();
            var start           = 0;
            var fizzBuzzService = new FizzBuzzService.Services.FizzBuzzService();
            var controller      = new FizzBuzzController(fizzBuzzService);

            //Act
            var result = await controller.GetAsync(start) as OkNegotiatedContentResult <List <string> >;

            //Assert
            //Assert.AreEqual(result.Content.Count, 100);
            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(new DirectoryInfo(@"C:\FizzBuzz\Persist\").GetFiles().Length, 1);
        }
Ejemplo n.º 4
0
        public void ShouldReturnCorrectHundredTimesFizzBuzz()
        {
            //Arrange
            var start           = 0;
            var fizzBuzzService = new FizzBuzzService.Services.FizzBuzzService();
            var controller      = new FizzBuzzController(fizzBuzzService);

            var TaskList = new List <Task <IHttpActionResult> >();

            //Act
            for (var i = 0; i < 100; i++)
            {
                var result = controller.GetAsync(start);
                TaskList.Add(result);
            }

            Task.WaitAll(TaskList.ToArray());

            //Assert
            TaskList.ForEach(o =>
                             Assert.AreEqual(
                                 ((OkNegotiatedContentResult <List <string> >)o.Result).Content.Count
                                 , 100));
        }