Пример #1
0
        public void GetNoteByTitle_NegativeTest_One()  // For Some Not Found
        {
            DummyData          DD        = new DummyData();
            List <GingerNoteC> dummy     = DD.DummyMock();
            string             notetitle = "SomeRandomSearchStringThatIsNotFound";
            string             type      = Type.Title;

            Mock <IGingerNoteRepo> MockRepository = new Mock <IGingerNoteRepo>();

            MockRepository.Setup(d => d.GetNoteByTitle(notetitle, type))
            .Returns(dummy.Where(d => d.NoteTitle == notetitle).ToList());

            GingerController gingerontroller = new GingerController(MockRepository.Object);
            var actual = gingerontroller.Get(notetitle, type);

            var NotFoundOR = actual as NotFoundObjectResult;

            Assert.NotNull(NotFoundOR);
        }
Пример #2
0
        public void GetNoteByTitle_NegativeTest_Two()  // For Some Bad Request
        {
            DummyData          DD        = new DummyData();
            List <GingerNoteC> dummy     = DD.DummyMock();
            string             notetitle = "SomeRandomSearchStringThatIsNotFound";
            string             type      = null;

            Mock <IGingerNoteRepo> MockRepository = new Mock <IGingerNoteRepo>();

            MockRepository.Setup(d => d.GetNoteByTitle(notetitle, type))
            .Returns(dummy);

            GingerController gingerontroller = new GingerController(MockRepository.Object);
            var actual = gingerontroller.Get(notetitle, type);

            var BadRequestOR = actual as BadRequestObjectResult;

            Assert.NotNull(BadRequestOR);
        }
Пример #3
0
        public void GetAllNote_PositiveTest()
        {
            DummyData          DD    = new DummyData();
            List <GingerNoteC> dummy = DD.DummyMock();                            // Arrange

            Mock <IGingerNoteRepo> MockRepository = new Mock <IGingerNoteRepo>(); // Removing Dependency

            MockRepository.Setup(d => d.GetAllNote()).Returns(dummy);

            GingerController gingerontroller = new GingerController(MockRepository.Object); // Act
            var actual = gingerontroller.Get();

            var okObjectResult = actual as OkObjectResult;

            Assert.NotNull(okObjectResult);

            var actualList = okObjectResult.Value as List <GingerNoteC>;

            Assert.NotNull(actualList); // Assert
            Assert.Equal(actualList.Count, dummy.Count);
        }
Пример #4
0
        public void GetNoteById_PositiveTest()
        {
            DummyData          DD    = new DummyData();
            List <GingerNoteC> dummy = DD.DummyMock();  // Arrange
            int NoteId = 2;

            Mock <IGingerNoteRepo> MockRepository = new Mock <IGingerNoteRepo>(); // Removing Dependency

            MockRepository.Setup(d => d.GetNote(NoteId)).Returns(dummy.FirstOrDefault(d => d.NoteId == NoteId));

            GingerController gingerontroller = new GingerController(MockRepository.Object); // Act
            var actual = gingerontroller.Get(NoteId);

            var okObjectResult = actual as OkObjectResult;

            Assert.NotNull(okObjectResult); // Assert

            var actualClass = okObjectResult.Value as GingerNoteC;

            Assert.NotNull(actualClass);

            Assert.Equal(NoteId, actualClass.NoteId);
        }