コード例 #1
0
ファイル: WasteType.cs プロジェクト: DEFRA/prsd-iws
        public WasteType(Guid importNotificationId,
                         string name,
                         BaselOecdCode baselOecdCode,
                         EwcCode ewcCode,
                         YCode yCode,
                         HCode hCode,
                         UnClass unClass,
                         ChemicalComposition chemicalComposition)
        {
            Guard.ArgumentNotDefaultValue(() => importNotificationId, importNotificationId);
            Guard.ArgumentNotNullOrEmpty(() => name, name);
            Guard.ArgumentNotNull(() => baselOecdCode, baselOecdCode);
            Guard.ArgumentNotNull(() => ewcCode, ewcCode);
            Guard.ArgumentNotNull(() => yCode, yCode);
            Guard.ArgumentNotNull(() => hCode, hCode);
            Guard.ArgumentNotNull(() => unClass, unClass);
            Guard.ArgumentNotDefaultValue(() => chemicalComposition, chemicalComposition);

            ImportNotificationId = importNotificationId;
            Name = name;

            var wasteCodes = new List <WasteTypeWasteCode>();

            WasteCodesCollection    = new List <WasteTypeWasteCode>();
            BaselOecdCodeNotListed  = baselOecdCode.NotListed;
            YCodeNotApplicable      = yCode.NotApplicable;
            HCodeNotApplicable      = hCode.NotApplicable;
            UnClassNotApplicable    = unClass.NotApplicable;
            ChemicalCompositionType = chemicalComposition;

            wasteCodes.AddRange(ewcCode.Codes);

            if (!BaselOecdCodeNotListed)
            {
                wasteCodes.Add(baselOecdCode.Code);
            }

            if (!YCodeNotApplicable)
            {
                wasteCodes.AddRange(yCode.Codes);
            }

            if (!HCodeNotApplicable)
            {
                wasteCodes.AddRange(hCode.Codes);
            }

            if (!UnClassNotApplicable)
            {
                wasteCodes.AddRange(unClass.Codes);
            }

            WasteCodesCollection = wasteCodes;
        }
コード例 #2
0
        public WasteType(Guid importNotificationId,
            string name,
            BaselOecdCode baselOecdCode,
            EwcCode ewcCode,
            YCode yCode,
            HCode hCode,
            UnClass unClass,
            ChemicalComposition chemicalComposition)
        {
            Guard.ArgumentNotDefaultValue(() => importNotificationId, importNotificationId);
            Guard.ArgumentNotNullOrEmpty(() => name, name);
            Guard.ArgumentNotNull(() => baselOecdCode, baselOecdCode);
            Guard.ArgumentNotNull(() => ewcCode, ewcCode);
            Guard.ArgumentNotNull(() => yCode, yCode);
            Guard.ArgumentNotNull(() => hCode, hCode);
            Guard.ArgumentNotNull(() => unClass, unClass);
            Guard.ArgumentNotDefaultValue(() => chemicalComposition, chemicalComposition);

            ImportNotificationId = importNotificationId;
            Name = name;

            var wasteCodes = new List<WasteTypeWasteCode>();

            WasteCodesCollection = new List<WasteTypeWasteCode>();
            BaselOecdCodeNotListed = baselOecdCode.NotListed;
            YCodeNotApplicable = yCode.NotApplicable;
            HCodeNotApplicable = hCode.NotApplicable;
            UnClassNotApplicable = unClass.NotApplicable;
            ChemicalCompositionType = chemicalComposition;

            wasteCodes.AddRange(ewcCode.Codes);

            if (!BaselOecdCodeNotListed)
            {
                wasteCodes.Add(baselOecdCode.Code);
            }

            if (!YCodeNotApplicable)
            {
                wasteCodes.AddRange(yCode.Codes);
            }

            if (!HCodeNotApplicable)
            {
                wasteCodes.AddRange(hCode.Codes);
            }

            if (!UnClassNotApplicable)
            {
                wasteCodes.AddRange(unClass.Codes);
            }

            WasteCodesCollection = wasteCodes;
        }
コード例 #3
0
ファイル: WasteType.cs プロジェクト: DEFRA/prsd-iws
        public void Update(string name,
                           BaselOecdCode baselOecdCode,
                           EwcCode ewcCode,
                           YCode yCode,
                           HCode hCode,
                           UnClass unClass)
        {
            Guard.ArgumentNotNullOrEmpty(() => name, name);
            Guard.ArgumentNotNull(() => baselOecdCode, baselOecdCode);
            Guard.ArgumentNotNull(() => ewcCode, ewcCode);
            Guard.ArgumentNotNull(() => yCode, yCode);
            Guard.ArgumentNotNull(() => hCode, hCode);
            Guard.ArgumentNotNull(() => unClass, unClass);

            Name = name;

            var wasteCodes    = new List <WasteTypeWasteCode>();
            var existingCodes = WasteCodes.ToList();

            BaselOecdCodeNotListed = baselOecdCode.NotListed;
            YCodeNotApplicable     = yCode.NotApplicable;
            HCodeNotApplicable     = hCode.NotApplicable;
            UnClassNotApplicable   = unClass.NotApplicable;

            foreach (var code in existingCodes)
            {
                WasteCodesCollection.Remove(code);
            }

            wasteCodes.AddRange(ewcCode.Codes);

            if (!BaselOecdCodeNotListed)
            {
                wasteCodes.Add(baselOecdCode.Code);
            }

            if (!YCodeNotApplicable)
            {
                wasteCodes.AddRange(yCode.Codes);
            }

            if (!HCodeNotApplicable)
            {
                wasteCodes.AddRange(hCode.Codes);
            }

            if (!UnClassNotApplicable)
            {
                wasteCodes.AddRange(unClass.Codes);
            }

            WasteCodesCollection = wasteCodes;
        }
コード例 #4
0
ファイル: WasteTypeTests.cs プロジェクト: DEFRA/prsd-iws
        public void CanCreateWasteType()
        {
            var wasteType = new WasteType(ImportNotificationId,
                                          "WasteTypeName",
                                          BaselOecdCode.CreateFor(AnyWasteCode(CodeType.Basel)),
                                          EwcCode.CreateFor(new[] { AnyWasteCode(CodeType.Ewc) }),
                                          YCode.CreateFor(new[] { AnyWasteCode(CodeType.Y) }),
                                          HCode.CreateFor(new[] { AnyWasteCode(CodeType.H) }),
                                          UnClass.CreateFor(new[] { AnyWasteCode(CodeType.Un) }),
                                          ChemicalComposition.Other);

            Assert.IsType <WasteType>(wasteType);
        }
コード例 #5
0
ファイル: WasteTypeTests.cs プロジェクト: DEFRA/prsd-iws
        public void UnClassNotApplicable_NotApplicableTrue()
        {
            var wasteType = new WasteType(ImportNotificationId,
                                          "WasteTypeName",
                                          BaselOecdCode.CreateNotListed(),
                                          EwcCode.CreateFor(new[] { AnyWasteCode(CodeType.Ewc) }),
                                          YCode.CreateNotApplicable(),
                                          HCode.CreateNotApplicable(),
                                          UnClass.CreateNotApplicable(),
                                          ChemicalComposition.Other);

            Assert.True(wasteType.UnClassNotApplicable);
        }
コード例 #6
0
ファイル: WasteTypeTests.cs プロジェクト: DEFRA/prsd-iws
 public void UnClassNull_Throws()
 {
     Assert.Throws <ArgumentNullException>(() => new WasteType(ImportNotificationId,
                                                               "WasteTypeName",
                                                               BaselOecdCode.CreateNotListed(),
                                                               EwcCode.CreateFor(new[]
     {
         AnyWasteCode(CodeType.Ewc)
     }),
                                                               YCode.CreateNotApplicable(),
                                                               HCode.CreateNotApplicable(),
                                                               null,
                                                               ChemicalComposition.Other));
 }
コード例 #7
0
ファイル: WasteTypeTests.cs プロジェクト: DEFRA/prsd-iws
 public void ImportNotificationIdDefaultValue_Throws()
 {
     Assert.Throws <ArgumentException>(() => new WasteType(Guid.Empty,
                                                           "WasteTypeName",
                                                           BaselOecdCode.CreateNotListed(),
                                                           EwcCode.CreateFor(new[]
     {
         AnyWasteCode(CodeType.Ewc)
     }),
                                                           YCode.CreateNotApplicable(),
                                                           HCode.CreateNotApplicable(),
                                                           UnClass.CreateNotApplicable(),
                                                           ChemicalComposition.Other));
 }
コード例 #8
0
ファイル: WasteTypeTests.cs プロジェクト: DEFRA/prsd-iws
 public void UnsetChemicalComposition_Throws()
 {
     Assert.Throws <ArgumentException>(() => new WasteType(ImportNotificationId,
                                                           "Name",
                                                           BaselOecdCode.CreateNotListed(),
                                                           EwcCode.CreateFor(new[]
     {
         AnyWasteCode(CodeType.Ewc)
     }),
                                                           YCode.CreateNotApplicable(),
                                                           HCode.CreateNotApplicable(),
                                                           UnClass.CreateNotApplicable(),
                                                           default(ChemicalComposition)));
 }
コード例 #9
0
ファイル: WasteTypeTests.cs プロジェクト: DEFRA/prsd-iws
        public void OecdCodeIsSet()
        {
            var oecdCode   = AnyWasteCode(CodeType.Oecd);
            var oecdCodeId = new Guid("A58E7CE8-FA46-4E35-A3ED-26E395678CA0");

            ObjectInstantiator <WasteCode> .SetProperty(x => x.Id, oecdCodeId, oecdCode);

            var wasteType = new WasteType(ImportNotificationId,
                                          "WasteTypeName",
                                          BaselOecdCode.CreateFor(oecdCode),
                                          EwcCode.CreateFor(new[] { AnyWasteCode(CodeType.Ewc) }),
                                          YCode.CreateNotApplicable(),
                                          HCode.CreateNotApplicable(),
                                          UnClass.CreateNotApplicable(),
                                          ChemicalComposition.Other);

            Assert.Equal(1, wasteType.WasteCodes.Count(wc => wc.WasteCodeId == oecdCodeId));
        }
コード例 #10
0
ファイル: WasteTypeTests.cs プロジェクト: DEFRA/prsd-iws
        public void EwcCodesAreSet()
        {
            var ewcCode   = AnyWasteCode(CodeType.Ewc);
            var ewcCodeId = new Guid("A4DA3323-B6BD-4245-B144-B9E05661BEC6");

            ObjectInstantiator <WasteCode> .SetProperty(x => x.Id, ewcCodeId, ewcCode);

            var wasteType = new WasteType(ImportNotificationId,
                                          "WateTypeName",
                                          BaselOecdCode.CreateNotListed(),
                                          EwcCode.CreateFor(new[] { ewcCode }),
                                          YCode.CreateNotApplicable(),
                                          HCode.CreateNotApplicable(),
                                          UnClass.CreateNotApplicable(),
                                          ChemicalComposition.Other);

            Assert.Equal(1, wasteType.WasteCodes.Count(wc => wc.WasteCodeId == ewcCodeId));
        }
コード例 #11
0
ファイル: WasteTypeTests.cs プロジェクト: DEFRA/prsd-iws
        public void BaselCodeIsSet()
        {
            var baselCode   = AnyWasteCode(CodeType.Basel);
            var baselCodeId = new Guid("72669DEE-1126-47B3-8C45-2395F54C82D8");

            ObjectInstantiator <WasteCode> .SetProperty(x => x.Id, baselCodeId, baselCode);

            var wasteType = new WasteType(ImportNotificationId,
                                          "WasteTypeName",
                                          BaselOecdCode.CreateFor(baselCode),
                                          EwcCode.CreateFor(new[] { AnyWasteCode(CodeType.Ewc) }),
                                          YCode.CreateNotApplicable(),
                                          HCode.CreateNotApplicable(),
                                          UnClass.CreateNotApplicable(),
                                          ChemicalComposition.Other);

            Assert.Equal(1, wasteType.WasteCodes.Count(wc => wc.WasteCodeId == baselCodeId));
        }
コード例 #12
0
ファイル: WasteTypeTests.cs プロジェクト: DEFRA/prsd-iws
        public void UnClassesAreSet()
        {
            var unCode   = AnyWasteCode(CodeType.Un);
            var unCodeId = new Guid("4B50E7AA-0136-444A-9185-FE31BE6CF98E");

            ObjectInstantiator <WasteCode> .SetProperty(x => x.Id, unCodeId, unCode);

            var wasteType = new WasteType(ImportNotificationId,
                                          "WateTypeName",
                                          BaselOecdCode.CreateNotListed(),
                                          EwcCode.CreateFor(new[] { AnyWasteCode(CodeType.Ewc) }),
                                          YCode.CreateNotApplicable(),
                                          HCode.CreateNotApplicable(),
                                          UnClass.CreateFor(new[] { unCode }),
                                          ChemicalComposition.Other);

            Assert.Equal(1, wasteType.WasteCodes.Count(wc => wc.WasteCodeId == unCodeId));
        }
コード例 #13
0
ファイル: WasteTypeTests.cs プロジェクト: DEFRA/prsd-iws
        public void HCodesAreSet()
        {
            var hCode   = AnyWasteCode(CodeType.H);
            var hCodeId = new Guid("B21D8610-EBB0-436F-BD26-D2F40B42B866");

            ObjectInstantiator <WasteCode> .SetProperty(x => x.Id, hCodeId, hCode);

            var wasteType = new WasteType(ImportNotificationId,
                                          "WateTypeName",
                                          BaselOecdCode.CreateNotListed(),
                                          EwcCode.CreateFor(new[] { AnyWasteCode(CodeType.Ewc) }),
                                          YCode.CreateNotApplicable(),
                                          HCode.CreateFor(new[] { hCode }),
                                          UnClass.CreateNotApplicable(),
                                          ChemicalComposition.Other);

            Assert.Equal(1, wasteType.WasteCodes.Count(wc => wc.WasteCodeId == hCodeId));
        }
コード例 #14
0
ファイル: WasteTypeTests.cs プロジェクト: DEFRA/prsd-iws
        public void YCodesAreSet()
        {
            var yCode   = AnyWasteCode(CodeType.Y);
            var yCodeId = new Guid("F416BD1D-56E9-45D8-9A4E-7476DF201AB2");

            ObjectInstantiator <WasteCode> .SetProperty(x => x.Id, yCodeId, yCode);

            var wasteType = new WasteType(ImportNotificationId,
                                          "WateTypeName",
                                          BaselOecdCode.CreateNotListed(),
                                          EwcCode.CreateFor(new[] { AnyWasteCode(CodeType.Ewc) }),
                                          YCode.CreateFor(new[] { yCode }),
                                          HCode.CreateNotApplicable(),
                                          UnClass.CreateNotApplicable(),
                                          ChemicalComposition.Other);

            Assert.Equal(1, wasteType.WasteCodes.Count(wc => wc.WasteCodeId == yCodeId));
        }
コード例 #15
0
        private EwcCode CreateEwcCode(IEnumerable <Guid> codeIds)
        {
            var wasteCodes = Task.Run(() => wasteCodeRepository.GetWasteCodesByIds(codeIds)).Result;

            return(EwcCode.CreateFor(wasteCodes));
        }
コード例 #16
0
ファイル: WasteTypeTests.cs プロジェクト: DEFRA/prsd-iws
 public void EwcCode_CreateFor_Null_Throws()
 {
     Assert.Throws <ArgumentNullException>(() => EwcCode.CreateFor(null));
 }
コード例 #17
0
ファイル: WasteTypeTests.cs プロジェクト: DEFRA/prsd-iws
 public void AnyEwcCodesWrongType_Throws(CodeType codeType)
 {
     Assert.Throws <ArgumentException>(() => EwcCode.CreateFor(new[] { AnyWasteCode(codeType) }));
 }