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

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

            DA.Parcel wh = new DA.Parcel()
            {
                TrackingId = id, State = DA.Parcel.StateEnum.DeliveredEnum
            };

            mock.Setup(foo => foo.GetByTrackingId(id)).Throws(new ParcelNotFoundExpection());

            IRecipientLogic receipientLogic = new RecipientLogic(mapper, mock.Object, NullLogger <RecipientLogic> .Instance);

            Assert.Throws <BusinessLayerException>(() => receipientLogic.TrackParcel(id));
        }
コード例 #2
0
ファイル: ReceipientLogicTests.cs プロジェクト: Jawohi/src
        public void TrackParcel_ReturnParcel()
        {
            string id = "123456789";

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

            DA.Parcel wh = new DA.Parcel()
            {
                TrackingId = id, State = DA.Parcel.StateEnum.DeliveredEnum
            };
            mock.Setup(foo => foo.GetByTrackingId(id)).Returns(wh);

            IRecipientLogic receipientLogic = new RecipientLogic(mapper, mock.Object, NullLogger <RecipientLogic> .Instance);

            Parcel p = receipientLogic.TrackParcel(id);

            Assert.NotNull(p);
            Assert.Equal(p.TrackingId, id);
            Assert.Equal(Parcel.StateEnum.DeliveredEnum, p.State);
        }