public VersionedApplication AddVersionedApplication(string applicationIdentifier, string applicationDescription,
     SemVersion startingVersion)
 {
     var versionedApplicationState = new VersionedApplicationState("", "");
     versionedApplicationState.BuildHistory.Add(new VersionControlIdEntry("", startingVersion));
     return new VersionedApplication(versionedApplicationState);
 }
        public VersionedApplication AddVersionedApplication(string applicationIdentifier, string applicationDescription,
                                                            SemVersion startingVersion)
        {
            var versionedApplicationState = new VersionedApplicationState("", "");

            versionedApplicationState.BuildHistory.Add(new VersionControlIdEntry("", startingVersion));
            return(new VersionedApplication(versionedApplicationState));
        }
        public void BuildVersionResetToZeroWhenMinorVersionIncremenmted()
        {
            var state = new VersionedApplicationState("test", "test");
            state.BuildHistory.Add(new VersionControlIdEntry(Guid.NewGuid().ToString(), new SemVersion(0, 0,0,build:"1")));
            var application = ConfigureVersionKeeperWithApplicationState(state);

            application.IncrementMinorVersion();

            Assert.That((object) application.Version.Build, Is.EqualTo("0"));
        }
        public void PatchVersionsAreResetWhenMinorVersionIncremented()
        {
            var state = new VersionedApplicationState("test", "test");
            state.BuildHistory.Add(new VersionControlIdEntry(Guid.NewGuid().ToString(), new SemVersion(0,0,1)));
            var application = ConfigureVersionKeeperWithApplicationState(state);

            application.IncrementMinorVersion();

            Assert.That((object) application.Version.Patch, Is.EqualTo(0));
        }
        public void WhenApplicationWithSameNameExistsReturnsDuplicateResult()
        {
            var state = new VersionedApplicationState("test", "description");
            var stateStoreSpy = new VersionApplicationStateStoreMock();
            stateStoreSpy.SetupApplicationStateToReturn(state);

            var classUnderTest = new ApplicationVersionKeeper(stateStoreSpy);

            var existingApplication = classUnderTest.AddVersionedApplication("test", "other description");
            Assert.That(existingApplication, Is.TypeOf<ExistingVersionedApplication>());
        }
        private static VersionedApplication ConfigureVersionKeeperWithApplicationState(VersionedApplicationState applicationState = null)
        {
            if (applicationState == null)
                applicationState = new VersionedApplicationState("name", "desc");

            var versionApplicationStateStoreMock = new VersionApplicationStateStoreMock();
            versionApplicationStateStoreMock.SetupApplicationStateToReturn(applicationState);
            var classUnderTest = new ApplicationVersionKeeper(versionApplicationStateStoreMock);
            VersionedApplication application = classUnderTest.AddVersionedApplication("name", "desc");
            return application;
        }
        public VersionedApplication AddVersionedApplication(string applicationIdentifier, string applicationDescription)
        {
            var existingApplication = _stateStore.Read(applicationIdentifier);

            if (existingApplication != null)
                return new ExistingVersionedApplication(existingApplication);

            var versionedApplicationState = new VersionedApplicationState(applicationIdentifier, applicationDescription);
            _stateStore.Write(versionedApplicationState);
            return new VersionedApplication(versionedApplicationState);
        }
        public void LatestsVersionControlIdIsRecordedAgainstNewMinorVersionNumber()
        {
            string versionControlId = Guid.NewGuid().ToString();
            var state = new VersionedApplicationState("test", "test");
            state.BuildHistory.Add(new VersionControlIdEntry(versionControlId, new SemVersion(0, 0, 0, build: "1")));
            var application = ConfigureVersionKeeperWithApplicationState(state);

            application.IncrementMinorVersion();

            var latestBuild = state.BuildHistory.Last();
            Assert.That(latestBuild.HighestVersion.Minor, Is.EqualTo(1));
            Assert.That(latestBuild.VersionControlId, Is.EqualTo(versionControlId));
        }
        public VersionedApplication AddVersionedApplication(string applicationIdentifier, string applicationDescription)
        {
            var existingApplication = _stateStore.Read(applicationIdentifier);

            if (existingApplication != null)
            {
                return(new ExistingVersionedApplication(existingApplication));
            }

            var versionedApplicationState = new VersionedApplicationState(applicationIdentifier, applicationDescription);

            _stateStore.Write(versionedApplicationState);
            return(new VersionedApplication(versionedApplicationState));
        }
 public void Write(VersionedApplicationState state)
 {
     throw new NotImplementedException();
 }
 public VersionedApplication(VersionedApplicationState state)
 {
     _state = state;
 }
        private static ApplicationVersionKeeper BuildUpClassWithNewApplication(string applicationName, VersionApplicationStateStoreMock stateStore = null)
        {
            if (stateStore == null)
                stateStore = new VersionApplicationStateStoreMock();

            var versionedApplicationState = new VersionedApplicationState(applicationName, "");
            stateStore.SetupApplicationStateToReturn(versionedApplicationState);
            var classUnderTest = new ApplicationVersionKeeper(stateStore);
            return classUnderTest;
        }
 public VersionedApplication(VersionedApplicationState state)
 {
     _state = state;
 }
 public void SetupApplicationStateToReturn(VersionedApplicationState applicationState)
 {
     _applicationStateToReturn = applicationState;
 }
 public void Write(VersionedApplicationState state)
 {
     _applicationName = state.ApplicationName;
     _applicationDescription = state.ApplicationDescription;
 }