コード例 #1
0
        public void NewItemsWithNullValues()
        {
            try
            {
                //Arrange
                Mock <IReceiveAdapterRepository> mockedDAL = new Mock <IReceiveAdapterRepository>();
                mockedDAL.Setup(x => x.RegisterReadItem(It.IsAny <Activity>())).Returns(1);
                mockedDAL.Setup(x => x.RegisterItem(It.IsAny <Activity>())).Returns(1);
                mockedDAL.Setup(x => x.ReadItem(It.IsAny <Activity>())).Returns(true);

                //Act
                ReceiveAdapterBL bl = new ReceiveAdapterBL(mockedDAL.Object, _registrationKey);
                bl.ReceiveActivityList(_sampleData.NewItemsWithNullValues());

                //Assert
                mockedDAL.Verify(x => x.RegisterItem(It.IsAny <Activity>()), Times.Never);
                mockedDAL.Verify(x => x.ReadItem(It.IsAny <Activity>()), Times.Never);
                mockedDAL.Verify(x => x.RegisterReadItem(It.IsAny <Activity>()), Times.Never);

                Assert.IsTrue(true);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(false, ex.Message);
            }
        }
コード例 #2
0
        public void RegisterNewItemsWithNullValues()
        {
            try
            {
                var list = _sampleData.NewItemsWithNullValues();
                foreach (var item in list)
                {
                    int returnValue = _receiveAdapterRepository.RegisterItem(item);

                    Assert.IsTrue(returnValue == -1);
                }
            }
            catch (Exception ex)
            {
                Assert.IsTrue(false, ex.Message);
            }
        }