Exemplo n.º 1
0
        public void MethodToTest()
        {
            // Arange
            var listOfBands = new List <Band>();

            listOfBands.Add(new Band {
                Name     = "Rush",
                Origin   = "Toronto, Canada",
                Genre    = "ProgRock",
                BestSong = "Red Barchetta"
            });


            Mock <IRepository> mockRepository = new Mock <IRepository>();

            mockRepository.Setup(x => x.GetBands()).Returns(listOfBands);

            // Act
            var bandController = new BandController(mockRepository.Object);

            bandController.MethodToTest();

            // Assert fluid
            bandController.Should().NotBeNull();
            listOfBands.Count.Should().Be(1);
            listOfBands[0].Name.Should().Be("Rush");

            // Assert standard
            Assert.IsNotNull(bandController);
            Assert.AreEqual(expected: 1, actual: listOfBands.Count);
            Assert.AreEqual(expected: "Rush", actual: listOfBands[0].Name);
        }
Exemplo n.º 2
0
        public void Should_Return_ListOfBands()
        {
            Mock <IRepository> mockRepository = new Mock <IRepository>();

            var listOfBands = new List <Band>();

            listOfBands.Add(new Band {
                Name = "Bayside", Origin = "Queens, New York", Genre = "Alternative", BestSong = "I And I"
            });

            mockRepository.Setup(p => p.GetBands()).Returns(listOfBands);
            var controller = new BandController(mockRepository.Object);

            controller.Should().NotBeNull();

            var result = controller.GetBands();

            result.Should().Equal(listOfBands);
        }
Exemplo n.º 3
0
        public void MethodTest()
        {
            var listOfBands = new List <Band>();

            listOfBands.Add(new Band
            {
                Name  = "Insync Maniacs",
                song  = "Fir Kabhi",
                genre = "emotional"
            });

            Mock <IRepository> mockRepository = new Mock <IRepository>();

            mockRepository.Setup(x => x.GetBands()).Returns(listOfBands);
            var bandController = new BandController(mockRepository.Object);

            bandController.Method();
            bandController.Should().NotBeNull();
        }
Exemplo n.º 4
0
        public void MethodToTest()
        {
            // CREATE LIST OF BANDS TO RETURN
            var ListofBands = new List <Band>();

            ListofBands.Add(new Band
            {
                Name     = "Uzay",
                Origin   = "İzmir",
                Genre    = "Rock",
                BestSong = "Sabır"
            });

            Mock <IRepository> mockRepository = new Mock <IRepository>();

            mockRepository.Setup(x => x.GetBands()).Returns(ListofBands);
            var bandController = new BandController(mockRepository.Object);

            bandController.MethodToTest();
            bandController.Should().NotBeNull();
        }