Exemplo n.º 1
0
        public VersionDetail IncrementVersion(IVersionRequest request)
        {
            var versions = GetVersions(request);

            var versionList = versions.OrderBy(x => new Version(x.Version.Major, x.Version.Minor)).Reverse();

            VersionSimple version = null;

            if (versionList.Count() == 0)
            {
                version.CreateIncrement(request);
            }
            else
            {
                version = versionList.First().Version;
                version.CalculateIncrement(request);
            }

            var versionDetail = new VersionDetail
            {
                Version     = version,
                CreatedDate = DateTime.Now,
                Product     = new Product
                {
                    Id = request.ProductId
                }
            };

            var created = _repository.Add(versionDetail);

            return(created);
        }
Exemplo n.º 2
0
        public void WithMinorArgumentException()
        {
            var version = new VersionSimple(8, 3, 0, 0);

            Action calculatedVersion = () => version.CreateIncrement(new VersionRequest
            {
                ProductId = 1,
                Minor     = 3
            });

            calculatedVersion.Should().Throw <ArgumentException>();
        }
Exemplo n.º 3
0
        public void WithProductId()
        {
            var version = new VersionSimple(8, 3, 0, 0);

            var calculatedVersion = version.CreateIncrement(new VersionRequest
            {
                ProductId = 1
            });

            calculatedVersion.Major.Should().Be(1);
            calculatedVersion.Minor.Should().Be(0);
            calculatedVersion.Build.Should().Be(0);
            calculatedVersion.Revision.Should().Be(0);
        }