public FizzBuzzTests()
        {
            var fizz = new FizzBuzzInput(3, Fizz);
            var buzz = new FizzBuzzInput(5, Buzz);

            _processor = new Console.FizzBuzz(fizz, buzz);
        }
        public void TestInitialize()
        {
            var fizz = new FizzBuzzInput(3, Fizz);
            var buzz = new FizzBuzzInput(5, Buzz);

            _processor = new Console.FizzBuzz(fizz, buzz);
        }
Esempio n. 3
0
        public void TestInitialize()
        {
            var fizz = new FizzBuzzInput(3, Fizz);
            var buzz = new FizzBuzzInput(5, Buzz);

            _processor = new Console.FizzBuzz(fizz, buzz);
        }
Esempio n. 4
0
        public void ShouldReturnCorrectObjectWithObjInput()
        {
            //arrange
            FizzBuzzInput        input    = new FizzBuzzInput(1);
            IFizzBuzzReturnValue expected = new FizzBuzzReturnValue(input);
            //act
            IFizzBuzzReturnValue actual = FizzBuzzErnieObj(input);

            //assert
            actual.Should().Be(expected);
        }
Esempio n. 5
0
        private static void Main(string[] args)
        {
            var fizz     = new FizzBuzzInput(3, "Fizz");
            var buzz     = new FizzBuzzInput(5, "Buzz");
            var fizzBuzz = new FizzBuzz(fizz, buzz);

            var processor = new FizzBuzzProcessor(1, 100, fizzBuzz, new FizzBuzzConsole());

            processor.Run();

            System.Console.ReadLine();
        }
        public void Constructor_Valid_Creates()
        {
            //Arrange

            //Act
            var actual = new FizzBuzzInput(1, "display");

            //Assert
            actual.Should().NotBeNull();
            actual.Divisor.Should().Be(1);
            actual.Display.Should().Be("display");
        }
        public void Constructor_Valid_Creates()
        {
            //Arrange


            //Act
            var actual = new FizzBuzzInput(1, "display");

            //Assert
            actual.Should().NotBeNull();
            actual.Divisor.Should().Be(1);
            actual.Display.Should().Be("display");
        }
        // public FizzBuzzModel context { get; set; }

        // public FizzBuzzRepository getvars= new FizzBuzzRepository();
        //  public IEnumerable<string> GetDisplay(int input)
        //{
        //   int x1 = Convert.ToInt32(input);
        //IEnumerable<string> val = new string[x1];
        //   for (int i = 1; i < x1; i++)
        //   {
        //       int[]val = i;
        //   }

        //   return val;
        //return context.number.GetType(string ,input);
        //   throw new NotImplementedException();
        //}

        public FizzBuzzOutput ComputeResult(FizzBuzzInput input)
        {
            FizzBuzzOutput output = new FizzBuzzOutput();
            int            num    = input.getNum();

            if (num >= 1 && num <= 1000)
            {
                output.setSuccess(true);
                output.setMessage("Printing list from 1 to " + num);
                // TODO compute the list
                List <string> resultSet = new List <string>();
                for (int i = 1; i <= num; i++)
                {
                    string element = "";
                    if (i % 3 == 0)
                    {
                        element = "fizz ";
                    }

                    if (i % 5 == 0)
                    {
                        element = element + "buzz";
                    }

                    if ((i % 3 != 0) && (i % 5 != 0))
                    {
                        element = "" + i;
                    }
                    resultSet.Add(element);
                }

                output.setResult(resultSet);
            }
            else
            {
                output.setSuccess(false);
                output.setMessage("enter a valid number between 1 and 1000");
            }
            return(output);
        }
Esempio n. 9
0
        //public ActionResult FizzBuzzView(List<FizzBuzzModel> model)
        //{
        //    List<FizzBuzzModel> Obj = new List<FizzBuzzModel>();
        //    Obj.Capacity = model.Capacity;
        //   // int demo = List<model>;
        //    //int demo = Convert.ToInt32(model);
        //    vars.GetDisplay(Obj.Capacity);



        //   return RedirectToAction("GetDetails");
        //}
        public ActionResult FizzBuzzView(FizzBuzzInput model)
        {
            IFizzBuzzRepository repository = new FizzBuzzRepository();
            FizzBuzzOutput      output     = repository.ComputeResult(model);

            if (output.isSuccess())
            {
                foreach (string s in output.getResult())
                {
                    TempData["Message"] = s;//  Debug.Print(s+" ");}
                }
            }
            else
            {
                TempData["Message"] = output.getMessage();
                //Console.WriteLine(output.getMessage());
            }

            // ViewBag.List = output;
            // TempData["Message"] =;
            //int idigit = Convert.ToInt32(Request["digit"].ToString());
            return(RedirectToAction("Index", output.getResult()));
        }
 private static Console.FizzBuzz SetupFizzBuzz(FizzBuzzInput fizz = null, FizzBuzzInput buzz = null)
 {
     return(new Console.FizzBuzz(fizz ?? SetupInput(), buzz ?? SetupInput()));
 }
Esempio n. 11
0
 private FizzBuzzReturnValue FizzBuzzErnieObj(FizzBuzzInput input)
 {
     return(new FizzBuzzReturnValue(new FizzBuzzInput(1)));
 }
Esempio n. 12
0
 public FizzBuzzReturnValue(FizzBuzzInput inputObj)
 {
     _inputObj = inputObj;
 }
 private static Console.FizzBuzz SetupFizzBuzz(FizzBuzzInput fizz = null, FizzBuzzInput buzz = null)
 {
     return new Console.FizzBuzz(fizz ?? SetupInput(), buzz ?? SetupInput());
 }