public void UpdatePackagingInfoReplacesItems()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                UKCompetentAuthority.England, 0);

            var packagingInfos = new List<PackagingInfo>
            {
                PackagingInfo.CreateOtherPackagingInfo("package description"),
                PackagingInfo.CreatePackagingInfo(PackagingType.Bag)
            };

            var newPackagingInfos = new List<PackagingInfo>
            {
                PackagingInfo.CreatePackagingInfo(PackagingType.Box),
                PackagingInfo.CreatePackagingInfo(PackagingType.Bulk)
            };

            notification.SetPackagingInfo(packagingInfos);

            notification.SetPackagingInfo(newPackagingInfos);

            Assert.Collection(notification.PackagingInfos,
                item => Assert.Equal(notification.PackagingInfos.ElementAt(0).PackagingType, PackagingType.Box),
                item => Assert.Equal(notification.PackagingInfos.ElementAt(1).PackagingType, PackagingType.Bulk));
        }
Ejemplo n.º 2
0
        public void UpdatePackagingInfoReplacesItems()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                                                           UKCompetentAuthority.England, 0);

            var packagingInfos = new List <PackagingInfo>
            {
                PackagingInfo.CreateOtherPackagingInfo("package description"),
                PackagingInfo.CreatePackagingInfo(PackagingType.Bag)
            };

            var newPackagingInfos = new List <PackagingInfo>
            {
                PackagingInfo.CreatePackagingInfo(PackagingType.Box),
                PackagingInfo.CreatePackagingInfo(PackagingType.Bulk)
            };

            notification.SetPackagingInfo(packagingInfos);

            notification.SetPackagingInfo(newPackagingInfos);

            Assert.Collection(notification.PackagingInfos,
                              item => Assert.Equal(notification.PackagingInfos.ElementAt(0).PackagingType, PackagingType.Box),
                              item => Assert.Equal(notification.PackagingInfos.ElementAt(1).PackagingType, PackagingType.Bulk));
        }
        public void CanAddPackagingInfo()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                UKCompetentAuthority.England, 0);

            notification.SetPackagingInfo(new[] { PackagingInfo.CreateOtherPackagingInfo("package description") });

            Assert.Equal(1, notification.PackagingInfos.Count());
        }
Ejemplo n.º 4
0
        public void CanAddPackagingInfo()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                                                           UKCompetentAuthority.England, 0);

            notification.SetPackagingInfo(new[] { PackagingInfo.CreateOtherPackagingInfo("package description") });

            Assert.Equal(1, notification.PackagingInfos.Count());
        }
        public PrenotificationInvalidPackagingTypeRuleTests()
        {
            this.repo = A.Fake <INotificationApplicationRepository>();

            notificationApplication = new NotificationApplication(Guid.NewGuid(), Core.Shared.NotificationType.Disposal, Core.Notification.UKCompetentAuthority.England, 1);

            var packagingInfos = new List <PackagingInfo>()
            {
                PackagingInfo.CreatePackagingInfo(Core.PackagingType.PackagingType.Bag),
                PackagingInfo.CreatePackagingInfo(Core.PackagingType.PackagingType.Box)
            };

            notificationApplication.SetPackagingInfo(packagingInfos);

            A.CallTo(() => repo.GetById(notificationId)).Returns(notificationApplication);

            rule = new PrenotificationInvalidPackagingTypeRule(repo);
        }
Ejemplo n.º 6
0
        public async Task UpdatePackagingInfoReplacesItems()
        {
            var packagingInfo1 = PackagingInfo.CreatePackagingInfo(PackagingType.Bag);
            var packagingInfo2 = PackagingInfo.CreatePackagingInfo(PackagingType.Box);
            var packagingInfo3 = PackagingInfo.CreatePackagingInfo(PackagingType.Bulk);

            try
            {
                context.NotificationApplications.Add(notification);

                await context.SaveChangesAsync();

                notificationId = notification.Id;

                notification.SetPackagingInfo(new[]
                {
                    packagingInfo1
                });

                await context.SaveChangesAsync();

                var count =
                    await context.Database.SqlQuery <int>(
                        "select count(id) from notification.PackagingInfo where NotificationId = @id",
                        new SqlParameter("id", notificationId)).SingleAsync();

                Assert.Equal(1, count);

                notification.SetPackagingInfo(new[]
                {
                    packagingInfo2,
                    packagingInfo3
                });

                await context.SaveChangesAsync();

                count =
                    await context.Database.SqlQuery <int>(
                        "select count(id) from notification.PackagingInfo where NotificationId = @id",
                        new SqlParameter("id", notificationId)).SingleAsync();

                Assert.Equal(2, count);
            }
            finally
            {
                if (context.Entry(packagingInfo1).State != EntityState.Detached)
                {
                    context.Entry(packagingInfo1).State = EntityState.Deleted;
                }

                if (context.Entry(packagingInfo2).State != EntityState.Detached)
                {
                    context.Entry(packagingInfo2).State = EntityState.Deleted;
                }

                if (context.Entry(packagingInfo3).State != EntityState.Detached)
                {
                    context.Entry(packagingInfo3).State = EntityState.Deleted;
                }

                context.DeleteOnCommit(notification);

                context.SaveChanges();
            }
        }