Example #1
0
        public Task <ElementResponse> GetElement(string elementId)
        {
            if (elementId == triggerExceptionId)
            {
                throw new TestExceptionInFakePSI();
            }

            var fakeElementResponse = new ElementResponse()
            {
                Success = true
            };

            if (elementId == nullResponseId)
            {
                fakeElementResponse.Data = null;
            }
            else
            {
                fakeElementResponse.Data = new Element()
                {
                    Id          = 3434,
                    Description = "First Floor"
                };
            }

            return(Task.FromResult(fakeElementResponse));
        }
Example #2
0
        private ElementResponse AddElementChores(Element element, int year)
        {
            var elementGenericChores = element.ElementGenericChores;

            ElementResponse ElementResponse = new ElementResponse();

            ElementResponse.Chores      = new List <ChoreResponse>();
            ElementResponse.TotalChores = 0;

            List <Chore> AllChoresElement = new List <Chore>();


            foreach (ElementGenericChore elemenGChore in elementGenericChores)
            {
                NewChoresGuideline newChoresGuideline = new NewChoresGuideline();
                newChoresGuideline.GenericChore = elemenGChore.GenericChore;
                newChoresGuideline.ElementId    = element.Id;

                GenericChore gChore       = elemenGChore.GenericChore;
                Period       gChorePeriod = gChore.Period;

                Chore LastChore = GetLastChore(element.Id, gChore.Id, year);

                if (LastChore == null)
                {
                    newChoresGuideline.TimeSpanToAddChores = GetDefaultTimeSpan(year);
                }
                else if (IsTimeSpanIncomplete(LastChore, year) == true)
                {
                    newChoresGuideline.TimeSpanToAddChores = ResumeTimeSpan(LastChore);
                }
                else
                {
                    continue;
                }

                List <Chore> choresAdded = AddingElements(newChoresGuideline);

                AllChoresElement.AddRange(choresAdded);

                ChoreResponse choreResponse = new ChoreResponse();
                choreResponse.TotalChores = choresAdded.Count();
                choreResponse.Period      = newChoresGuideline.GenericChore.Period;

                ElementResponse.Chores.Add(choreResponse);
                ElementResponse.TotalChores += choreResponse.TotalChores;
            }

            InsertChoresToDatabase(AllChoresElement);
            _formatsService.AddFormatValuesToChores(AllChoresElement);

            return(ElementResponse);
        }
Example #3
0
        private InstallationResponse AddChoreToElements(IEnumerable <Element> elements, int year)
        {
            InstallationResponse InstallationResponse = new InstallationResponse();

            InstallationResponse.TotalChores = 0;
            InstallationResponse.Elements    = new List <ElementResponse>();

            foreach (Element element in elements)
            {
                ElementResponse elementResponse = AddElementChores(element, year);
                elementResponse.ElementRef = element.Ref;

                InstallationResponse.Elements.Add(elementResponse);
                InstallationResponse.TotalChores += elementResponse.TotalChores;
            }

            return(InstallationResponse);
        }
        public async Task can_access_element_data_from_response()
        {
            Element responseData;
            var     fakeRepository      = new Mock <IPsi2000Api>();
            var     fakeElementResponse = new ElementResponse()
            {
                Data = new Element()
                {
                    Id          = fakeId,
                    Description = fakeDescription
                }
            };

            fakeRepository
            .Setup(m => m.GetElement(It.IsAny <string>()))
            .Returns(Task.FromResult(fakeElementResponse));

            asbestosService = new AsbestosService(fakeRepository.Object, fakeLogger.Object);
            responseData    = await asbestosService.GetElement("random string");

            Assert.Equal(fakeId, responseData.Id);
            Assert.Equal(fakeDescription, responseData.Description);
        }
 public void DellPhoto(ElementResponse response) => DellPhotoBLL.Execute(response.Txt);