public void GetById_ShouldGetStudent() { var fakeRepo = new FakeStudentRepository(); var student1 = new Student() { StudentId = 1, FirstName = "Minko", LastName = "Markov", School = new School(), Grade = 5 }; var student2 = new Student() { StudentId = 2, FirstName = "Minko", LastName = "Markov", School = new School(), Grade = 5 }; fakeRepo.Add(student2); fakeRepo.Add(student1); var server = new InMemoryHttpServer <Student>("http://localhost/", fakeRepo); var response = server.CreateGetRequest("api/students/1"); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.IsNotNull(response.Content); }
public void Should_Return_Error_When_Email_Exists() { var studentRepository = new FakeStudentRepository(); var emailService = new FakeEmailService(); var handler = new SubscriptionHandler(studentRepository, emailService); var command = new CreateBoletoSubscriptionCommand { FirstName = "Iago João", LastName = "Peixoto", Document = "45608646088", Email = "*****@*****.**", BarCode = "", BoletoNumber = "", PaymentNumber = "", PaidDate = DateTime.Now, ExpireDate = DateTime.Now.AddMonths(1), Total = 60, TotalPaid = 60, Payer = "Iago João Peixoto", PayerDocument = "45608646088", PayerDocumentType = EDocumentType.CPF, PayerEmail = "*****@*****.**", PayerStreet = "Beco Acioly", PayerNumber = "413", PayerNeighborhood = "São Vicente de Paula", PayerCity = "Parintins", PayerState = "AM", PayerCountry = "Brasil", PayerZipCode = "69153421" }; handler.Handle(command); Assert.AreEqual(false, handler.Valid); }
public void DeleteStudent_ShouldDeleteStudent() { Student studentEnitity = new Student() { StudentId = 1, FirstName = "Minko", LastName = "Markov", School = new School(), Grade = 5 }; var fakeRepo = new FakeStudentRepository(); fakeRepo.Add(studentEnitity); fakeRepo.Add(studentEnitity); var controller = new StudentsController(fakeRepo); studentEnitity.FirstName = "Kiro"; SetupController(controller); controller.PutStudent(studentEnitity.StudentId, studentEnitity); controller.DeleteStudent(studentEnitity.StudentId); Assert.AreEqual(1, fakeRepo.Entities.Count()); }
public void Find_ShouldReturnOneStudent() { Mark markEntity = new Mark() { Subject = "Math", Value = 5 }; var marks = new List <Mark>(); marks.Add(markEntity); Student studentEnitity = new Student() { FirstName = "Minko", LastName = "Markov", School = new School(), Grade = 5, Marks = marks }; var fakeRepo = new FakeStudentRepository(); fakeRepo.Add(studentEnitity); var controller = new StudentsController(fakeRepo); SetupController(controller); var students = controller.Find("Math", 5); Assert.IsNotNull(students); Assert.AreEqual(1, students.Count()); }
public void Update_ShouldUpdateStudent() { Student studentEnitity = new Student() { StudentId = 1, FirstName = "Minko", LastName = "Markov", School = new School(), Grade = 5 }; var fakeRepo = new FakeStudentRepository(); fakeRepo.Add(studentEnitity); fakeRepo.Add(studentEnitity); var controller = new StudentsController(fakeRepo); studentEnitity.FirstName = "Kiro"; SetupController(controller); controller.PutStudent(studentEnitity.StudentId, studentEnitity); var student = controller.Get(studentEnitity.StudentId); Assert.IsNotNull(student); Assert.AreEqual("Kiro", student.FirstName); }
public void ShouldReturnErrorWhenDocumentExists() { var emailService = new FakeEmailService(); var studentRepository = new FakeStudentRepository(); var handler = new SubscriptionHandle(studentRepository, emailService); var command = new CreateBoletoSubscriptionCommand(); command.FirstName = "Tony"; command.LastName = "Stark"; command.Document = "99999999999"; command.Email = "*****@*****.**"; command.BoletoNumber = "1324254342"; command.BarCode = "1234456245"; command.PaymentNumber = "3134324"; command.PaidDate = DateTime.Now; command.ExpireDate = DateTime.Now.AddMonths(1); command.Total = 60; command.TotalPaid = 60; command.Payer = "Empresas Stark"; command.PayerDocument = "12345678910"; command.PayerDocumentType = EDocumentType.CPF; command.PayerEmail = "*****@*****.**"; command.Street = "rua teste"; command.City = "cidade teste"; command.State = "estado teste"; command.Country = "USA"; command.ZipCode = "877659870"; handler.Handle(command); Assert.AreEqual(false, handler.Valid); }
public SubscriptionHandlerTests() { _mockEmailService = new FakeEmailService(); _mockStudentRepository = new FakeStudentRepository(); _boletoCommand = new CreateBoletoSubscriptionCommand { BarCode = "1234567890123", BoletoNumber = "111", City = "Curitiba", Country = "Brasil", Document = "99999999999", Email = "*****@*****.**", ExpireDate = DateTime.Now.AddDays(1), FirstName = "Bruce", LastName = "Wayne", Neighborhood = "Gotham", PaidDate = DateTime.Now, Payer = "Alfred", PayerDocument = "88888888888", PayerDocumentType = Domain.Enums.EDocumentType.CPF, PayerEmail = "*****@*****.**", PaymentNumber = "987654321", State = "PR", Street = "Rua Top", StreetNumber = "666", Total = 60, TotalPaid = 60, ZipCode = "88888-777" }; }
public async Task SetFirstnameTestAsync() { // No valid value { var repository = new FakeStudentRepository(); var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var student = await Student.BuildAsync(validator, ValidSexId, NotValidFirstname, ValidMiddlename, ValidLastname, ValidCallsign); Assert.AreEqual(null, student.Firstname); } // Valid value { var repository = new FakeStudentRepository(); var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var student = await Student.BuildAsync(validator, ValidSexId, ValidFirstname, ValidMiddlename, ValidLastname, ValidCallsign); Assert.AreEqual(ValidFirstname, student.Firstname); } }
public async Task ExcludeAllStudentsTestAsync() { var groupRepository = new FakeGroupRepository(); var group = await GroupBuilder.BuildAsync(groupRepository, 1); var studentRepository = new FakeStudentRepository(); var student1 = await StudentBuilder.BuildAsync(studentRepository, 1); var student2 = await StudentBuilder.BuildAsync(studentRepository, 2); group.IncludeStudent(student1); Assert.AreEqual(true, group.ExcludeAllStudents()); Assert.AreEqual(0, group.Grouping.Count); group.IncludeStudent(student2); Assert.AreEqual(true, group.ExcludeAllStudents()); Assert.AreEqual(0, group.Grouping.Count); group.IncludeStudent(student1); group.IncludeStudent(student2); Assert.AreEqual(true, group.ExcludeAllStudents()); Assert.AreEqual(0, group.Grouping.Count); Assert.AreEqual(false, group.ExcludeAllStudents()); Assert.AreEqual(0, group.Grouping.Count); }
public void TestQueryStudent() { var studentRepository = new FakeStudentRepository(); var expr = StudentQueries.GetStudent("34843436801"); var result = studentRepository.GetStudents(expr); var expected = 1; var actual = result.Count(); Assert.AreEqual(expected, actual); }
public void PostStudent_WhenStudentIsNull_StudentShouldnotBeAdded() { var fakeRepo = new FakeStudentRepository(); var controller = new StudentsController(fakeRepo); Student studentEnitity = null; SetupController(controller); controller.PostStudent(studentEnitity); Assert.AreEqual(0, fakeRepo.Entities.Count); }
public void GetAllStudentsTest() { var repository = new FakeStudentRepository(); var school = new TownSchool { Name = "School", Location = "Town" }; var student = new Student { FirstName = "Ivan", LastName = "Ivanov", Age = 9, Grade = 4, TownSchool = school }; repository.entities.Add(student); var server = new InMemoryHttpServer("http://localhost/"); var response = server.CreateGetRequest("api/students"); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.IsNotNull(response.Content); }
public void GetStudentInvalidTest() { var repository = new FakeStudentRepository(); var school = new TownSchool { Name = "School", Location = "Town" }; var firstStudent = new Student { FirstName = "Ivan", LastName = "Ivanov", Age = 9, Grade = 4, TownSchool = school }; var secondStudent = new Student { FirstName = "Peter", LastName = "Petrov", Age = 15, Grade = 9, TownSchool = school }; repository.entities.Add(firstStudent); repository.entities.Add(secondStudent); var server = new InMemoryHttpServer("http://localhost/"); var response = server.CreateGetRequest("api/students/3"); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); }
public void SexIdTest() { const string propertyName = nameof(StudentValidator.SexId); const int min = SexIdMin; const int max = SexIdMax; var repository = new FakeStudentRepository(); // Check less than min { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = min - 1; validator.SexId(value); var errors = ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 1); var error = ValidationsTestHelper.CheckErrorType <ComparisonValidationError <int> >(errors); Assert.AreEqual(ComparisonResultType.Less, error.ComparisonResult); Assert.AreEqual(min, error.ComparisonValue); } // Check is min { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = min; validator.SexId(value); ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 0); } // Check is max { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = max; validator.SexId(value); ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 0); } // Check bigger than max { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = max + 1; validator.SexId(value); var errors = ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 1); var error = ValidationsTestHelper.CheckErrorType <ComparisonValidationError <int> >(errors); Assert.AreEqual(ComparisonResultType.More, error.ComparisonResult); Assert.AreEqual(max, error.ComparisonValue); } }
public void GetAllSeveralStudentsControllerTest() { var repository = new FakeStudentRepository(); var school = new TownSchool { Name = "School", Location = "Town" }; var firstStudent = new Student { FirstName = "Ivan", LastName = "Ivanov", Age = 9, Grade = 4, TownSchool = school }; var secondStudent = new Student { FirstName = "Peter", LastName = "Petrov", Age = 15, Grade = 9, TownSchool = school }; var thirdStudent = new Student { FirstName = "Todor", LastName = "Todorov", Age = 7, Grade = 1, TownSchool = school }; repository.entities.Add(firstStudent); repository.entities.Add(secondStudent); repository.entities.Add(thirdStudent); var controller = new StudentsController(repository); var studentsModels = controller.GetAll(); Assert.IsTrue(studentsModels.Count() == 3); }
public void GetAllStudentsControllerTest() { var repository = new FakeStudentRepository(); var school = new TownSchool { Name = "School", Location = "Town" }; var student = new Student { FirstName = "Ivan", LastName = "Ivanov", Age = 9, Grade = 4, TownSchool = school }; repository.entities.Add(student); var controller = new StudentsController(repository); var studentsModels = controller.GetAll(); Assert.IsTrue(studentsModels.Count() == 1); Assert.AreEqual(student.FirstName, studentsModels.First().FirstName); Assert.AreEqual(student.LastName, studentsModels.First().LastName); Assert.AreEqual(student.Age, studentsModels.First().Age); Assert.AreEqual(student.Grade, studentsModels.First().Grade); }
public void DeleteStudentsControllerTest() { var repository = new FakeStudentRepository(); var school = new TownSchool { Name = "School", Location = "Town" }; var firstStudent = new Student { FirstName = "Ivan", LastName = "Ivanov", Age = 9, Grade = 4, TownSchool = school }; var secondStudent = new Student { FirstName = "Peter", LastName = "Petrov", Age = 15, Grade = 9, TownSchool = school }; var thirdStudent = new Student { FirstName = "Todor", LastName = "Todorov", Age = 7, Grade = 1, TownSchool = school }; var controller = new StudentsController(repository); var firstStudentModel = controller.Post(firstStudent); var secondStudentModel = controller.Post(secondStudent); var thirdStudentModel = controller.Post(thirdStudent); controller.Delete(3); Assert.IsTrue(controller.GetAll().Count() == 2); Assert.IsTrue(controller.GetAll().Count(x => x.FirstName == thirdStudent.FirstName) == 0); }
public void Validate_WhenStudentIsValid_ReturnsTrue() { //Arrange var fakeRepo = new FakeStudentRepository(); fakeRepo.HasRegistered = true; var validator = new StudentValidator(fakeRepo); var student = new Student(); student.Age = 20; //Act var result = validator.Validate(student); //Assert Assert.IsTrue(result); }
public void GetStudentBySubjectMarkTest() { var repository = new FakeStudentRepository(); var school = new TownSchool { Name = "School", Location = "Town" }; var firstStudent = new Student { FirstName = "Ivan", LastName = "Ivanov", Age = 9, Grade = 4, TownSchool = school }; var secondStudent = new Student { FirstName = "Peter", LastName = "Petrov", Age = 15, Grade = 9, TownSchool = school }; firstStudent.Marks.Add(new Mark { Subject = "Math", Value = 5, Student = firstStudent }); secondStudent.Marks.Add(new Mark { Subject = "History", Value = 4, Student = secondStudent }); secondStudent.Marks.Add(new Mark { Subject = "IT", Value = 6, Student = secondStudent }); repository.entities.Add(firstStudent); repository.entities.Add(secondStudent); var server = new InMemoryHttpServer("http://localhost/"); var response = server.CreateGetRequest("api/students?subject=Math&value=5"); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.IsNotNull(response.Content); }
public void PostStudent_WhenStudentIsValid_StudentShouldBeAdded() { var fakeRepo = new FakeStudentRepository(); var controller = new StudentsController(fakeRepo); Student studentEnitity = new Student() { FirstName = "Minko", LastName = "Markov", School = new School(), Grade = 5 }; SetupController(controller); controller.PostStudent(studentEnitity); Assert.AreEqual(1, fakeRepo.Entities.Count); }
public void PostStudent_WhenValidStudent_ShouldReturnStatusCode201() { var fakeRepo = new FakeStudentRepository(); var server = new InMemoryHttpServer <Student>("http://localhost/", fakeRepo); var response = server.CreatePostRequest("api/students", new Student() { FirstName = "Minko", LastName = "Markov", School = new School(), Grade = 5 }); Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); }
public void GetByIdStudentsControllerTest() { var repository = new FakeStudentRepository(); var school = new TownSchool { Name = "School", Location = "Town" }; var firstStudent = new Student { FirstName = "Ivan", LastName = "Ivanov", Age = 9, Grade = 4, TownSchool = school }; var secondStudent = new Student { FirstName = "Peter", LastName = "Petrov", Age = 15, Grade = 9, TownSchool = school }; var thirdStudent = new Student { FirstName = "Todor", LastName = "Todorov", Age = 7, Grade = 1, TownSchool = school }; repository.entities.Add(firstStudent); repository.entities.Add(secondStudent); repository.entities.Add(thirdStudent); var controller = new StudentsController(repository); var studentModel = controller.Get(1); Assert.AreEqual(secondStudent.FirstName, studentModel.FirstName); Assert.AreEqual(secondStudent.LastName, studentModel.LastName); Assert.AreEqual(secondStudent.Age, studentModel.Age); Assert.AreEqual(secondStudent.Grade, studentModel.Grade); }
public async Task ExcludeFromAllGroupsTestAsync() { Assert.Fail("Has to be in integration tests"); var groupRepository = new FakeGroupRepository(); var studentRepository = new FakeStudentRepository(); var group1 = await GroupBuilder.BuildAsync(groupRepository, 1); var group2 = await GroupBuilder.BuildAsync(groupRepository, 2); var student = await StudentBuilder.BuildAsync(studentRepository, 1); group1.IncludeStudent(student); group2.IncludeStudent(student); Assert.AreEqual(true, student.ExcludeFromAllGroups()); Assert.AreEqual(0, group1.Grouping.Count); Assert.AreEqual(0, group2.Grouping.Count); }
public void GetById_ShouldGetStudent() { Student studentEnitity = new Student() { FirstName = "Minko", LastName = "Markov", School = new School(), Grade = 5 }; var fakeRepo = new FakeStudentRepository(); fakeRepo.Entities.Add(studentEnitity); fakeRepo.Entities.Add(studentEnitity); var controller = new StudentsController(fakeRepo); SetupController(controller); var student = controller.Get(1); Assert.IsNotNull(student); }
public void GetAll_WhenOneStudent_ShouldReturnStatusCode200AndNotNullContent() { var fakeRepo = new FakeStudentRepository(); var student = new Student() { FirstName = "Minko", LastName = "Markov", School = new School(), Grade = 5 }; fakeRepo.Add(student); var server = new InMemoryHttpServer <Student>("http://localhost/", fakeRepo); var response = server.CreateGetRequest("api/students"); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.IsNotNull(response.Content); }
public void FirstnameTest() { const string propertyName = nameof(StudentValidator.Firstname); const int upperBoundary = FirstnameUpperBoundary; var repository = new FakeStudentRepository(); // Check for null { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); string value = null; validator.Firstname(ref value); var errors = ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 1); ValidationsTestHelper.CheckErrorType <NullValidationError>(errors); } // Check is empty { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = ""; validator.Firstname(ref value); var errors = ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 1); ValidationsTestHelper.CheckErrorType <EmptyValidationError <IEnumerable <char> > >(errors); } // Whitespaces check without boundary crossing { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = new string(Enumerable.Range(1, upperBoundary).Select(x => ' ').ToArray()); validator.Firstname(ref value); var errors = ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 1); ValidationsTestHelper.CheckErrorType <WhitespacesValidationError>(errors); } // Whitespaces check with boundary crossing { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = new string(Enumerable.Range(1, upperBoundary + 1).Select(x => ' ').ToArray()); validator.Firstname(ref value); var errors = ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 1); ValidationsTestHelper.CheckErrorType <WhitespacesValidationError>(errors); } // Upper boundary check without crossing { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = new string(Enumerable.Range(1, upperBoundary).Select(x => 'x').ToArray()); validator.Firstname(ref value); ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 0); } // Upper boundary check with crossing { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = new string(Enumerable.Range(1, upperBoundary + 1).Select(x => 'x').ToArray()); validator.Firstname(ref value); var errors = ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 1); ValidationsTestHelper.CheckErrorType <LengthComparisonValidationError>(errors); ValidationsTestHelper.CheckUpperBoundaryCross( (LengthComparisonValidationError)validator.Errors[propertyName][0], upperBoundary); } }
public async Task CallsignTestAsync() { const string propertyName = nameof(StudentValidator.Callsign); const int lowerBoundary = CallsignLowerBoundary; const int upperBoundary = CallsignUpperBoundary; var repository = new FakeStudentRepository(); // Check for null { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); string value = null; validator.Callsign(ref value); ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 0); } // Check is empty { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = ""; validator.Callsign(ref value); ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 0); } // Whitespaces check without boundary crossing { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = new string(Enumerable.Range(1, upperBoundary).Select(x => ' ').ToArray()); validator.Callsign(ref value); var errors = ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 1); ValidationsTestHelper.CheckErrorType <WhitespacesValidationError>(errors); } // Whitespaces check with boundary crossing { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = new string(Enumerable.Range(1, upperBoundary + 1).Select(x => ' ').ToArray()); validator.Callsign(ref value); var errors = ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 1); ValidationsTestHelper.CheckErrorType <WhitespacesValidationError>(errors); } // Lower boundary check without crossing { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = new string(Enumerable.Range(1, lowerBoundary).Select(x => 'x').ToArray()); validator.Callsign(ref value); ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 0); } // Lower boundary check with crossing { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = new string(Enumerable.Range(1, lowerBoundary - 1).Select(x => 'x').ToArray()); validator.Callsign(ref value); var errors = ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 1); ValidationsTestHelper.CheckErrorType <LengthComparisonValidationError>(errors); ValidationsTestHelper.CheckLowerBoundaryCross( (LengthComparisonValidationError)validator.Errors[propertyName][0], lowerBoundary); } // Upper boundary check without crossing { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = new string(Enumerable.Range(1, upperBoundary).Select(x => 'x').ToArray()); validator.Callsign(ref value); ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 0); } // Upper boundary check with crossing { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); var value = new string(Enumerable.Range(1, upperBoundary + 1).Select(x => 'x').ToArray()); validator.Callsign(ref value); var errors = ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 1); ValidationsTestHelper.CheckErrorType <LengthComparisonValidationError>(errors); ValidationsTestHelper.CheckUpperBoundaryCross( (LengthComparisonValidationError)validator.Errors[propertyName][0], upperBoundary); } // Check for uniqueness { var validator = new DefaultStudentValidator(new StudentValidationService(repository)); string value = null; await validator.CallsignUniqueness(value); ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 0); value = new string(Enumerable.Range(1, lowerBoundary).Select(x => 'x').ToArray()); await validator.CallsignUniqueness(value); ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 0); var student = await Student.BuildAsync(validator, 1, "firstname", "middlename", "lastname", value); await repository.AddAsync(student); await validator.CallsignUniqueness(value); var errors = ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 1); ValidationsTestHelper.CheckErrorType <UniquenessValidationError <string> >(errors); value = null; await validator.CallsignUniqueness(value); ValidationsTestHelper.CheckErrorsCount(validator, propertyName, 1); ValidationsTestHelper.CheckErrorType <UniquenessValidationError <string> >(errors); } }
public void PostStudentsControllerTest() { var repository = new FakeStudentRepository(); var school = new TownSchool { Name = "School", Location = "Town" }; var student = new Student { FirstName = "Ivan", LastName = "Ivanov", Age = 9, Grade = 4, TownSchool = school }; var controller = new StudentsController(repository); var studentModel = controller.Post(student).Content.ReadAsStringAsync().Result; Student studentDeserialized = JsonConvert.DeserializeObject<Student>(studentModel); Assert.IsTrue(controller.GetAll().Count() == 1); Assert.IsNotNull(studentDeserialized); Assert.AreEqual(student.FirstName, studentDeserialized.FirstName); Assert.AreEqual(student.LastName, studentDeserialized.LastName); Assert.AreEqual(student.Age, studentDeserialized.Age); Assert.AreEqual(student.Grade, studentDeserialized.Grade); }
public IndexModel(FakeStudentRepository repo) { Repo = repo; Students = Repo.GetStudents(); }
public void TestInitialize() { _StudentRepository = new FakeStudentRepository(); }
public void PostStudentInvalidNameTest() { var repository = new FakeStudentRepository(); var school = new TownSchool { Name = "School", Location = "Town" }; var student = new Student { FirstName = null, LastName = "Ivanov", Age = 9, Grade = 4, TownSchool = school }; var server = new InMemoryHttpServer("http://localhost/"); var response = server.CreatePostRequest("api/students", student); Assert.AreEqual(HttpStatusCode.InternalServerError, response.StatusCode); }