Ejemplo n.º 1
0
        public void Should_Get_One_By_Id()
        {
            int id = 1;

            Expect.Once.On(this.mockDataAccess).
            Method("Select").
            With(NMock2.Is.EqualTo("FAA-2015"), IsList.Equal(new List <string> {
                "*"
            }), NMock2.Is.EqualTo("students1"), IsDictionary.Equal(new Dictionary <string, object> {
                { "id", id }
            })).
            Will(Return.Value(new List <Record>()
            {
                this.testRecords[0]
            }));

            Student student = this.studentManager.GetOneById(id);

            Assert.AreEqual(1, student.Id);
            Assert.AreEqual("Firstname1", student.FirstName);
            Assert.AreEqual("Lastname1", student.LastName);
            Assert.AreEqual("A", student.FatherInitial);
            Assert.AreEqual("10000000001", student.PIN);
            Assert.AreEqual("City1", student.City);
            Assert.AreEqual("Address1", student.Address);
            Assert.AreEqual("Highschool1", student.Highschool);
            Assert.AreEqual("Spec1", student.Specialization);
            Assert.AreEqual(8.10D, student.AdmissionExamGrade);
            Assert.AreEqual(8.75D, student.BaccalaureatAverageGrade);
            Assert.AreEqual(9.00D, student.BaccalaureatMaximumGrade);

            this.mocks.VerifyAllExpectationsHaveBeenMet();
        }
Ejemplo n.º 2
0
        public void Should_Get_All_Students()
        {
            Expect.Once.On(this.mockDataAccess).
            Method("Select").
            With(NMock2.Is.EqualTo("FAA-2015"), IsList.Equal(new List <string> {
                "*"
            }), NMock2.Is.EqualTo("students1"), IsDictionary.Equal(new Dictionary <string, object> {
            })).
            Will(Return.Value(this.testRecords));

            List <Student> studentList = this.studentManager.GetAll();

            Assert.AreEqual(3, studentList.Count);
            Assert.IsInstanceOf <List <Student> >(studentList);

            this.mocks.VerifyAllExpectationsHaveBeenMet();
        }
Ejemplo n.º 3
0
        public void Should_Get_One_By_Id_Throw_Error_If_Multiple_Results()
        {
            int id = 1;

            Expect.Once.On(this.mockDataAccess).
            Method("Select").
            With(NMock2.Is.EqualTo("FAA-2015"), IsList.Equal(new List <string> {
                "*"
            }), NMock2.Is.EqualTo("students1"), IsDictionary.Equal(new Dictionary <string, object> {
                { "id", id }
            })).
            Will(Return.Value(this.testRecords));

            Student student = this.studentManager.GetOneById(id);

            this.mocks.VerifyAllExpectationsHaveBeenMet();
        }