public void TestInitialize()
        {
            //Arrange
            mock = new Mock <IAthletesRepository>();

            //Mock the Athlete Data
            athletes = new List <Athlete>
            {
                new Athlete {
                    Pk_Athlete_Id = 1, Fk_Sport_Id = 1, FullName = "albert calamatta", Email = "*****@*****.**", MobileNo = "5198032269"
                },
                new Athlete {
                    Pk_Athlete_Id = 2, Fk_Sport_Id = 2, FullName = "amanda davidson", Email = "*****@*****.**", MobileNo = "5198032269"
                },
                new Athlete {
                    Pk_Athlete_Id = 3, Fk_Sport_Id = 3, FullName = "corutney bell", Email = "*****@*****.**", MobileNo = "5198032269"
                }
            };

            // populate the mock object with our sample data
            mock.Setup(m => m.Athletes).Returns(athletes.AsQueryable());

            //pass the mock to the 2nd constructor
            controller = new AthletesController(mock.Object);
        }
Beispiel #2
0
        public void TestInitalize()
        {
            // create a new mock data object to hold a fake list of athletes
            mock = new Mock <IAthletesMock>();

            // populate mock list
            athletes = new List <Athlete>
            {
                new Athlete {
                    athlete_id   = 82,
                    athlete_name = "Rodrigo",
                    athlete_age  = 25,
                    sport_id     = 2
                },

                new Athlete {
                    athlete_id   = 100,
                    athlete_name = "Hanna",
                    athlete_age  = 250,
                    sport_id     = 3
                },

                new Athlete {
                    athlete_id   = 81,
                    athlete_name = "ROMULERA",
                    athlete_age  = 35,
                    sport_id     = 4
                }
            };

            mock.Setup(m => m.Athlete).Returns(athletes.AsQueryable());
            controller = new AthletesController(mock.Object);
        }
        public void Get_Zero_Items()
        {
            TestHelpers.SetupDbSet(this.mockSet, new List <athlete>());

            AthletesController controller = new AthletesController(this.mockContext.Object);

            IQueryable <athlete> athlete = controller.GetAthletes();

            Assert.IsNotNull(athlete);
            Assert.AreEqual(0, athlete.Count());
        }
        public void Get_Should_Return_Items()
        {
            TestHelpers.SetupDbSet(this.mockSet, this.data);

            AthletesController controller = new AthletesController(this.mockContext.Object);

            IQueryable <athlete> athlete = controller.GetAthletes();

            Assert.IsNotNull(athlete);
            Assert.AreNotEqual(0, athlete.Count());
        }
        public void AnalyseIndex()
        {
            // Arrange
            AthletesController controller = new AthletesController();

            // Act
            ViewResult result = controller.AthletesIndex() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
        public void Create()
        {
            // Arrange
            AthletesController controller = new AthletesController();

            // Act
            ViewResult result = controller.Create() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
        public void Get_Sport_By_ID_Should_Return_Sport()
        {
            TestHelpers.SetupDbSet(this.mockSet, this.data);

            AthletesController controller = new AthletesController(this.mockContext.Object);

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();

            IHttpActionResult response = controller.GetAthlete(data.First().id);

            var athlete      = response as OkNegotiatedContentResult <athlete>;
            var coutryResult = athlete.Content;

            Assert.IsNotNull(response);
            Assert.IsNotNull(coutryResult);
            Assert.AreEqual(data.First(), coutryResult);
        }
Beispiel #8
0
 public AthleteTest()
 {
     db = new OlympicsWiki.DB.AppDBContext();
     athletesController = new AthletesController(db);
 }