Example #1
0
        public void HoursIsEditableByProviderFalseIfCaseFinalized()
        {
            var testProvider = new Providers.Provider()
            {
                ID = 1
            };
            var finalization = new Cases.HoursFinalization();
            var hours        = new Hours();
            var period       = new Domain2.Cases.MonthlyPeriod();
            var c            = new Cases.Case();

            hours.Provider = new Providers.Provider()
            {
                ID = 1
            };
            hours.Status            = HoursStatus.Pending;
            finalization.ProviderID = 1;
            finalization.Provider   = testProvider;
            c.Periods = new List <Cases.MonthlyPeriod>();
            c.Periods.Add(period);
            period.Finalizations = new List <Cases.HoursFinalization>();
            period.Finalizations.Add(finalization);
            hours.Case = c;

            Assert.IsFalse(hours.IsEditableByProvider(testProvider));
        }
        public QuAP(
            Guid id,
            Qualification qualification,
            Providers.Provider provider)
        {
            Throw.IfNull(id, nameof(id));
            Throw.IfNull(qualification, nameof(qualification));
            Throw.IfNull(provider, nameof(provider));

            ID            = id;
            Qualification = qualification;
            Provider      = provider;
        }
        public void Provider_Should_Delete_Infrastructure()
        {
            //Arrang
            var fileSystemMock = new Mock <IFileManager>();

            fileSystemMock.Setup(w => w.DeleteDirectory(It.IsAny <string>()))
            .Verifiable();

            //Act
            var provider = new Providers.Provider(_providerName, fileSystemMock.Object);

            provider.DeleteInfrastructure("UAT");

            //Assert
            fileSystemMock.Verify(mock => mock.DeleteDirectory(@"c:\test\UAT"), Times.Once());
        }
Example #4
0
        public void HoursIsEditableByProviderFalseIfNoSameProvider()
        {
            var testProvider = new Providers.Provider()
            {
                ID = 1
            };
            var hours = new Hours();

            hours.Provider = new Providers.Provider()
            {
                ID = 2
            };

            bool sut = hours.IsEditableByProvider(testProvider);

            Assert.IsFalse(sut);
        }
Example #5
0
        public void HoursIsEditableByProviderTrueifAllConditionsPass()
        {
            var testProvider = new Providers.Provider()
            {
                ID = 1
            };
            var hours = new Hours();

            hours.Provider = new Providers.Provider()
            {
                ID = 1
            };
            hours.Status = HoursStatus.Pending;
            hours.Case   = new Cases.Case();

            Assert.IsTrue(hours.IsEditableByProvider(testProvider));
        }
Example #6
0
        public void HoursIsEditableByProviderFalseIfSSGParentNotSame()
        {
            var testProvider = new Providers.Provider()
            {
                ID = 1
            };
            var hours = new Hours();

            hours.Provider = new Providers.Provider()
            {
                ID = 1
            };
            hours.Status      = HoursStatus.Pending;
            hours.Case        = new Cases.Case();
            hours.ID          = 12345;
            hours.SSGParentID = 54321;

            Assert.IsFalse(hours.IsEditableByProvider(testProvider));
        }
Example #7
0
        public void HoursIsEditableByProviderFalseIfNotPendingOrCommitted()
        {
            var testProvider = new Providers.Provider()
            {
                ID = 1
            };
            var hours = new Hours();

            hours.Provider = new Providers.Provider()
            {
                ID = 1
            };

            hours.Status = HoursStatus.FinalizedByProvider;
            Assert.IsFalse(hours.IsEditableByProvider(testProvider));

            hours.Status = HoursStatus.ProcessedComplete;
            Assert.IsFalse(hours.IsEditableByProvider(testProvider));

            hours.Status = HoursStatus.ScrubbedByAdmin;
            Assert.IsFalse(hours.IsEditableByProvider(testProvider));
        }
        public void Provider_Should_Create_Linux_VirtualMachine_Infrastructure_Json_File()
        {
            //Arrang
            int cpu = 8;
            int ram = 4;
            int hdd = 40;
            LinuxDistribution linuxDistribution = LinuxDistribution.Suse;

            var expectedObject = new VirtualMachineResource
            {
                CPU             = cpu,
                HardDisk        = hdd,
                RAM             = ram,
                OperatingSystem = linuxDistribution.ToString()
            };

            var fileSystemMock = new Mock <IFileManager>();

            fileSystemMock.Setup(w => w.WriteJsonFile(It.IsAny <object>(),
                                                      It.IsAny <string>(),
                                                      It.IsAny <string>()))
            .Verifiable();

            //Act
            var provider = new Providers.Provider(_providerName, fileSystemMock.Object);
            var infra    = provider.CreateInfrastructure("UAT");

            infra.VirtualMachine(new Linux(linuxDistribution), hdd, ram, cpu);


            //Assert
            fileSystemMock.Verify(mock => mock.WriteJsonFile(It.IsAny <object>(),
                                                             It.IsAny <string>(),
                                                             It.IsAny <string>()), Times.Once());
            fileSystemMock.Verify(mock => mock.WriteJsonFile(expectedObject,
                                                             @"c:\test\UAT\VirtualMachine",
                                                             "UAT_Server.json"), Times.Once());
        }
Example #9
0
        // Determine if this hours entry is allowed to be edited by the specified provider
        public bool IsEditableByProvider(Providers.Provider provider)
        {
            // only allow edits if this provider owns it
            if (this.Provider.ID != provider.ID)
            {
                return(false);
            }

            // only allow edits to pending and committed hours
            if (this.Status != HoursStatus.Pending && this.Status != HoursStatus.ComittedByProvider)
            {
                return(false);
            }

            // make sure the month isn't finalized
            var period = this.Case.Periods?.Where(x => x.FirstDayOfMonth == new DateTime(this.Date.Year, this.Date.Month, 1)).SingleOrDefault();

            if (period != null)
            {
                var finalization = period.Finalizations.Where(x => x.ProviderID == provider.ID).SingleOrDefault();
                if (finalization != null)
                {
                    return(false);
                }
            }

            // make sure if we're an SSG then this is the master entry for it
            if (this.SSGParentID.HasValue)
            {
                if (this.SSGParentID.Value != this.ID)
                {
                    return(false);
                }
            }

            return(true);
        }
        public void Provider_Should_Create_SQL_Database_Infrastructure_Json_File()
        {
            //Arrang
            string     instance       = "example";
            SqlCharset charset        = SqlCharset.utf32;
            string     collation      = "collation1";
            string     userName       = "******";
            string     password       = "******";
            var        expectedObject = new DatabaseResource
            {
                Instance  = instance,
                Collation = collation,
                Charset   = charset.ToString(),
                UserName  = userName,
                Password  = password
            };

            var fileSystemMock = new Mock <IFileManager>();

            fileSystemMock.Setup(w => w.WriteJsonFile(It.IsAny <object>(),
                                                      It.IsAny <string>(),
                                                      It.IsAny <string>()))
            .Verifiable();


            //Act
            var provider = new Providers.Provider(_providerName, fileSystemMock.Object);
            var infra    = provider.CreateInfrastructure("UAT");

            infra.Database().SQL(instance, charset, collation, userName, password);;

            //Assert
            fileSystemMock.Verify(mock => mock.WriteJsonFile(expectedObject,
                                                             @"c:\test\UAT\Database",
                                                             "UAT_SQL.json"), Times.Once());
        }