public void EmptyPackagingInfosThrows() { var emptyPackagingInfos = new PackagingInfo[0]; Assert.Throws<ArgumentException>(() => new MovementDetails(MovementId, shipmentQuantity, emptyPackagingInfos)); }
public void EmptyPackagingInfosThrows() { var emptyPackagingInfos = new PackagingInfo[0]; Assert.Throws <ArgumentException>(() => new MovementDetails(MovementId, shipmentQuantity, emptyPackagingInfos)); }
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 CantSetOtherDescriptionToEmptyString() { Action createPackagingInfo = () => PackagingInfo.CreateOtherPackagingInfo(string.Empty); Assert.Throws <ArgumentException>(createPackagingInfo); }
public void CantSetOtherDescriptionToNull() { Action createPackagingInfo = () => PackagingInfo.CreateOtherPackagingInfo(null); Assert.Throws <ArgumentNullException>(createPackagingInfo); }
public void CantCreateOtherWithoutDescription() { Action createPackagingInfo = () => PackagingInfo.CreatePackagingInfo(PackagingType.Other); Assert.Throws <InvalidOperationException>(createPackagingInfo); }
static void Pack(string[] args, string outputFile) { PackagingInfo p = new PackagingInfo(); string addFile = CommandLineParser.GetArgumentValue(args, "addfile", ""); string addFileName = Path.GetFileName(addFile); p.Files = new List <AddFileInfo>(); p.Files.Add(new AddFileInfo(addFile, "%Root Folder%\\" + addFileName)); p.Operations = new List <ExecuteOperationInfo>(); for (int i = 0; i < 10; i++) { string opeFile = CommandLineParser.GetArgumentValue(args, "opefile" + (i + 1), null); string opeArg = CommandLineParser.GetArgumentValue(args, "opearg" + (i + 1), ""); if (opeFile == null) { break; } p.Operations.Add(new ExecuteOperationInfo(opeFile, opeArg)); } p.Option = new OptionInfo(); p.Option.IsCompressFile = CommandLineParser.GetArgumentValue(args, "compress", "true").ToLower() == "true"; p.Option.IsCreateRandomBytes = CommandLineParser.GetArgumentValue(args, "genrandombytes", "true").ToLower() == "true"; p.Option.RandomBytes = CommandLineParser.GetArgumentValue(args, "randombytes", "").ToHexArray(); var storage = new XmPackagingStorage(); storage.Pack(p, outputFile); }
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 async Task CanAddPackagingInfo() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0); context.NotificationApplications.Add(notification); notification.SetPackagingInfo(new[] { PackagingInfo.CreatePackagingInfo(PackagingType.Bag) }); await context.SaveChangesAsync(); 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); }
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(); } }