コード例 #1
0
ファイル: StaffLogicTests.cs プロジェクト: Jawohi/src
        public void ReportParcelDelivery_IsOk()
        {
            string trackingId = "123456789";

            DA.Parcel p = new DA.Parcel()
            {
                TrackingId = trackingId
            };

            Mock <IParcelRepository> parcelRepoMock = new Mock <IParcelRepository>();

            parcelRepoMock.Setup(foo => foo.GetByTrackingId(trackingId)).Returns(p);
            parcelRepoMock.Setup(foo => foo.Update(It.IsAny <DA.Parcel>()));

            Mock <IHopRepository>     hopRepoMock = new Mock <IHopRepository>();
            Mock <IWebhookRepository> hookMock    = new Mock <IWebhookRepository>();
            List <DA.Webhook>         webhooks    = new List <DA.Webhook>
            {
                new DA.Webhook(),
                new DA.Webhook()
            };

            hookMock.Setup(foo => foo.GetByTrackingId(trackingId)).Returns(webhooks);

            IStaffLogic staffLogic = new StaffLogic(mapper, parcelRepoMock.Object, hopRepoMock.Object, hookMock.Object, NullLogger <StaffLogic> .Instance);

            //if it doesn't throw, it's ok
            staffLogic.ReportParcelDelivery(trackingId);
        }
コード例 #2
0
ファイル: StaffLogicTests.cs プロジェクト: Jawohi/src
        public void ReportParcelDelivery_GetByTrackingIdExpection()
        {
            string trackingId = "123456789";

            Mock <IParcelRepository> parcelRepoMock = new Mock <IParcelRepository>();

            parcelRepoMock.Setup(foo => foo.GetByTrackingId(trackingId)).Throws(new ParcelNotFoundExpection());

            Mock <IHopRepository>     hopRepoMock = new Mock <IHopRepository>();
            Mock <IWebhookRepository> hookMock    = new Mock <IWebhookRepository>();

            IStaffLogic staffLogic = new StaffLogic(mapper, parcelRepoMock.Object, hopRepoMock.Object, hookMock.Object, NullLogger <StaffLogic> .Instance);

            Assert.Throws <BusinessLayerException>(() => staffLogic.ReportParcelDelivery(trackingId));
        }