Exemplo n.º 1
0
        public void Test_Check_Member_Is_Added()
        {
            //Arrange
            var mockService = new Mock <IMemberService>();

            mockService.Setup(service => service.Add(It.Is <Entity.Member>((i) =>
                                                                           i.FirstName.Equals("TestFirstName") &&
                                                                           i.LastName.Equals("TestLastName") &&
                                                                           i.DateOfBirth.Equals("10/10/1990") &&
                                                                           i.Email.Equals("*****@*****.**")
                                                                           ))).Returns(true);

            var membersController = new MembersController(mockService.Object);

            //Act
            var IsAdded = membersController.Add(new Models.MemberModel()
            {
                MemberId    = 0,
                FirstName   = "TestFirstName",
                LastName    = "TestLastName",
                DateOfBirth = "10/10/1990",
                Email       = "*****@*****.**"
            });

            //Assert
            Assert.IsTrue(IsAdded);
        }
Exemplo n.º 2
0
        public void Test_Check_Member_Is_Added()
        {
            var mockMember = new Mock <IMemberService>();

            mockMember.SetupProperty(member => member.FirstName, "SampleFirstName")
            .SetupProperty(member => member.LastName, "SampleLastName")
            .SetupProperty(member => member.Email, "*****@*****.**")
            .SetupProperty(member => member.DateOfBirth, "01/01/2000");
            mockMember.Setup(member => member.Add(mockMember.Object)).Returns(true);

            var membersController = new MembersController(mockMember.Object);
            var IsAdded           = membersController.Add(mockMember.Object);

            Assert.IsTrue(IsAdded);
        }
Exemplo n.º 3
0
        public Member(string firstName, string middleName, string lastName, DateTime birthday, string city, bool isRegular)
        {
            MembersController mc = new MembersController();

            mc.Add(
                new Param("firstName", firstName),
                new Param("middleName", middleName),
                new Param("lastName", lastName),
                new Param("city", city),
                new Param("birthday", birthday),
                new Param("isRegular", isRegular)
                );
            Member m = mc.GetLastAdded();

            this.id         = m.id;
            this.firstName  = m.firstName;
            this.middleName = m.middleName;
            this.lastName   = m.lastName;
            this.birthday   = m.birthday;
            this.city       = m.city;
            this.isRegular  = m.isRegular;
        }