Esempio 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);
        }
Esempio n. 2
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();
        }