Exemplo n.º 1
0
        public List <DTOSize> ValidateSizes(ICollection <DTOSize> sizes, out string error)
        {
            var result = new List <DTOSize>();

            error = null;
            foreach (var size in sizes)
            {
                if (size.Position.Id != this.Id)
                {
                    error += Texts.Instance.SizeCorrespondsToAnotherPosition(size.Name) + " /n";
                    continue;
                }
                if (Size.DoesSizeExist(size, result, out string existError))
                {
                    error += existError + " /n";
                    continue;
                }
                if (Size.DoesSizeNameExist(size, result, out existError))
                {
                    error += existError + " /n";
                    continue;
                }
                result.Add(size);
            }
            return(result);
        }
Exemplo n.º 2
0
        public void DoesSizeExistFail_DTOList()
        {
            var size1 = new DTOSize(1, "1", new Money(1), new DTO.Position(1, "1", "1"));
            var size2 = new DTOSize(2, "2", new Money(1), new DTO.Position(1, "1", "1"));
            var size3 = new DTOSize(3, "3", new Money(1), new DTO.Position(1, "1", "1"));
            var sizes = new List <DTOSize>()
            {
                size1, size2
            };
            var result = Size.DoesSizeExist(size3, sizes, out var error);

            Assert.IsFalse(result);
            Assert.AreEqual($"Size {size3.Name} cannot be found", error);
        }
Exemplo n.º 3
0
        public void DoesSizeExistSuccess_DTOList()
        {
            var size1 = new DTOSize(1, "1", new Money(1), new DTO.Position(1, "1", "1"));
            var size2 = new DTOSize(2, "2", new Money(1), new DTO.Position(1, "1", "1"));
            var size3 = new DTOSize(1, "3", new Money(1), new DTO.Position(1, "1", "1"));
            var sizes = new List <DTOSize>()
            {
                size1, size2
            };
            var result = Size.DoesSizeExist(size3, sizes, out var error);

            Assert.IsTrue(result);
            Assert.AreEqual($"Size {size3.Name} already exists", error);
        }