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());
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #11
0
        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));
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }