public void ReaderApiCreateCreated() { var readerManagerFake = new Mock<IReaderManager>(); var excelManagerFake = new Mock<IExcelManager>(); var controller = new ReaderApiController(readerManagerFake.Object, excelManagerFake.Object); controller.Request = new HttpRequestMessage(); var result = controller.Create(this.fixture.Create<ReaderBusinessModel>()); Assert.AreEqual(HttpStatusCode.Created, result.StatusCode); }
public void ReaderApiCreateBadRequest() { var readerManagerFake = new Mock<IReaderManager>(); var excelManagerFake = new Mock<IExcelManager>(); var controller = new ReaderApiController(readerManagerFake.Object, excelManagerFake.Object); controller.Request = new HttpRequestMessage(); var result = controller.Create(null); Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode); }
public void ReaderApiControllerGetReaderByIdBadRequest() { var readerManagerFake = new Mock<IReaderManager>(); var excelManagerFake = new Mock<IExcelManager>(); readerManagerFake.Setup(m => m.GetReaderById(It.IsAny<int>())).Returns((ReaderBusinessModel)null); var controller = new ReaderApiController(readerManagerFake.Object, excelManagerFake.Object); controller.Request = new HttpRequestMessage(); controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); var result = controller.GetById(1); Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode); }
public void ReaderApiGetReadersOK() { var readerManagerFake = new Mock<IReaderManager>(); var excelManagerFake = new Mock<IExcelManager>(); var gridModel = this.fixture.Create<ReadersGridModel>(); readerManagerFake.Setup(m => m.GetReadersForGrid(It.IsAny<IEnumerable<KeyValuePair<string,string>>>(), 1, 2, "", "")).Returns(gridModel); var controller = new ReaderApiController(readerManagerFake.Object, excelManagerFake.Object); controller.Request = new HttpRequestMessage(); controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); var result = controller.GetReaders(1, 2, string.Empty, string.Empty); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); }