public void TestPutMethod() { var TestNotePut = new ToDo() { Id = new ObjectId("5b71298a6a2e663634872a62"), Text = "Johnny", IsPinned = true, Title = "FooBar", Labels = new List <Label> { new Label { LabelName = "red label" }, new Label { LabelName = "black label" } }, CheckLists = new List <Checklist> { new Checklist { ChecklistData = "soda", IsChecked = true }, new Checklist { ChecklistData = "water", IsChecked = false } } }; var objId = new ObjectId("5b71298a6a2e663634872a62"); FakeDataAccess fakeData = new FakeDataAccess(); PrototypeController _controller = new PrototypeController(fakeData); var result = _controller.Put("5b71298a6a2e663634872a62", TestNotePut); var notePosted = result as OkResult; Assert.Equal(200, notePosted.StatusCode); }
public void TestGetAll() { FakeDataAccess fakeData = new FakeDataAccess(); PrototypeController _controller = new PrototypeController(fakeData); var result = _controller.Get(); Assert.Equal(2, result.Count()); }
public void DataAccessDeleteDataFile() { var mock = new Mock <IFileInfo>(); var dataAccess = new FakeDataAccess(mock.Object); mock.Setup(x => x.Delete()); dataAccess.Delete(); mock.Verify(x => x.Delete(), Times.Once); }
public void DataAccessStoreData() { var mock = new Mock <IFileInfo>(); var dataAccess = new FakeDataAccess(mock.Object); mock.Setup(x => x.Write()); dataAccess.StoreData("Test"); mock.Verify(x => x.Write(), Times.Once); }
public void DataAccessRetrieveData() { var mock = new Mock <IFileInfo>(); var dataAccess = new FakeDataAccess(mock.Object); mock.Setup(x => x.Read()); dataAccess.RetrieveDataAsText(); mock.Verify(x => x.Read(), Times.Once); }
public void TestDeleteMethod() { var objId = new ObjectId("5b71298a6a2e663634872a62"); FakeDataAccess fakeData = new FakeDataAccess(); PrototypeController _controller = new PrototypeController(fakeData); var result = _controller.Delete("5b71298a6a2e663634872a62"); var notePosted = result as OkResult; Assert.Equal(200, notePosted.StatusCode); }
public void PostNote() { FakeDataAccess fakeData = new FakeDataAccess(); PrototypeController _controller = new PrototypeController(fakeData); var result = _controller.Post(NoteToPost); var notePosted = result as OkObjectResult; var note = notePosted.Value as ToDo; Assert.Equal(3, note.NotesId); }
public void ConvertModelToCsv_NullList_Fail() { //Arrange List <Person> peopleList = new List <Person>(); //Act var convList = FakeDataAccess.ConvertModelToCsv(peopleList); //Assert Assert.NotNull(convList); }
public void TestGetByQuery() { var objId = new ObjectId("5b71298a6a2e663634872a61"); FakeDataAccess fakeData = new FakeDataAccess(); PrototypeController _controller = new PrototypeController(fakeData); var result = _controller.GetNotesByQuery(true, "", ""); var notePosted = result as ObjectResult; var note = notePosted.Value as List <ToDo>; Assert.Equal(1, note.Count); }
public void TestGetById() { var objId = new ObjectId("5b71298a6a2e663634872a62"); FakeDataAccess fakeData = new FakeDataAccess(); PrototypeController _controller = new PrototypeController(fakeData); var result = _controller.GetNotesById("5b71298a6a2e663634872a62"); var notePosted = result as ObjectResult; var note = notePosted.Value as ToDo; Assert.Equal(objId, note.Id); }
public void AddPersonToPeopleList_ThrowException_Pass(string firstName, string lastName, string email, string param) { //Arrange Person newPerson = new Person { FirstName = firstName, LastName = lastName, Email = email }; List <Person> peopleList = new List <Person>(); //Act //Assert Assert.Throws <ArgumentException>(param, () => FakeDataAccess.AddPersonToPeopleList(peopleList, newPerson)); }
public void ConvertModelToCsv_Pass() { //Arrange List <Person> peopleList = new List <Person>(); peopleList.Add(new Person { FirstName = "Test", LastName = "Person", Email = "*****@*****.**", Balance = 150 }); //Act var convList = FakeDataAccess.ConvertModelToCsv(peopleList); //Assert Assert.NotNull(peopleList); }
public void AddPersonToPeopleList_Pass() { //Arrange Person newPerson = new Person { FirstName = "Test", LastName = "Person", Email = "*****@*****.**", Balance = 150 }; List <Person> peopleList = new List <Person>(); //Act FakeDataAccess.AddPersonToPeopleList(peopleList, newPerson); //Assert Assert.True(peopleList.Count == 1); Assert.Contains <Person>(newPerson, peopleList); }