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

            DA.Parcel p = new DA.Parcel()
            {
                TrackingId = trackingId
            };
            DA.Warehouse w = new DA.Warehouse()
            {
                Code = code
            };

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

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

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

            hopRepoMock.Setup(foo => foo.GetByCode(code)).Returns(w);
            Mock <IWebhookRepository> hookMock = new Mock <IWebhookRepository>();

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

            Assert.Throws <BusinessLayerException>(() => staffLogic.ReportParcelHop(trackingId, code));
        }
コード例 #2
0
ファイル: StaffLogicTests.cs プロジェクト: Jawohi/src
        public void ReportParcelHop_GetByTrackingIdExpection()
        {
            string trackingId = "123456789";
            string code       = "987654321";

            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.ReportParcelHop(trackingId, code));
        }
コード例 #3
0
ファイル: StaffLogicTests.cs プロジェクト: Jawohi/src
        public void ReportParcelHop_IsOk()
        {
            string trackingId = "123456789";
            string code       = "987654321";

            DA.Parcel p = new DA.Parcel()
            {
                TrackingId = trackingId
            };
            DA.Warehouse w = new DA.Warehouse()
            {
                Code = code
            };

            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>();

            hopRepoMock.Setup(foo => foo.GetByCode(code)).Returns(w);
            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.ReportParcelHop(trackingId, code);
        }