Beispiel #1
0
        //teskbook
        public void TestGetBook()
        {
            Mock <ModelOperation> moc = new Mock <ModelOperation>();

            List <BookStore> bookModel = new List <BookStore>()
            {
                new BookStore
                {
                    BookId           = 1,
                    BookName         = "LifeStory",
                    AuthorFirsttName = "Arvindh",
                    AuthorlastName   = "Gosam",
                    Gender           = "M",
                    PYear            = 2013,
                    BookPrice        = 353,
                    Flag             = 1
                }
            };

            moc.Setup(m => m.GetDetails()).Returns(new List <BookStoreModel>());
            var controller         = new BookStoreController(moc.Object);
            IHttpActionResult http = controller.Get();
            var actual             = http as OkNegotiatedContentResult <List <BookStoreModel> >;

            CollectionAssert.Equals(actual, bookModel);
        }
Beispiel #2
0
        public async Task BookStoreController_Get_Should_Return_ActionResult()
        {
            //Arrange
            var controller = new BookStoreController();

            //Act
            var result = await controller.Get();

            //Assert
            Assert.IsType <JsonResult>(result);
        }
Beispiel #3
0
        public async Task BookStoreController_Get_Should_Return_Correct_BookStore_Data()
        {
            //Arrange
            var controller = new BookStoreController();

            //Act


            var result = await controller.Get();

            var json = result.ToJson <BookStore>();

            //Assert
            Assert.True(json[0].Name == "Waterstones", $"Assert failed, received {json[0].Name} ");
            Assert.True(json[0].PostCode == "PO19 1QD", $"Assert failed, received {json[0].PostCode} ");
            Assert.True(json[0].TelephoneNumber == "01234 773030", $"Assert failed, received {json[0].TelephoneNumber} ");
        }