public HotToHelpInfoManagementTests()
 {
     _howToHelpInformationService = ServiceProvider.Instance.Resolve <IHowToHelpInformationService>();
     _accountManagementService    = ServiceProvider.Instance.Resolve <IAccountManagementService>();
     _howToHelpInformationService.BecomeVolunteerUrl = RequestUriHelper.OrganizationInfoUri;
     _howToHelpInformationService.DonateInfoUrl      = RequestUriHelper.HowToHelpUri;
     _accountManagementService.RequestUri            = RequestUriHelper.JwtTokenUri;
     _testingObject = TestingObjectProvider.Instance.HowToHelpInfo;
     _token         = _accountManagementService.SignIn(TestingObjectProvider.Instance.Login).Result;
 }
Exemplo n.º 2
0
        public async Task <bool> UpdateOrCreateHelpInfo(HowToHelpInfo helpInfo, HowToHelpInfoType type, string token, CancellationToken cancelationToken = new CancellationToken())
        {
            string currentUrl;

            if (!GetCurrentUrl(type, out currentUrl))
            {
                return(false);
            }

            Func <string, HowToHelpInfo, string, CancellationToken, Task <bool> > methodToExecute = _restService.ExecutePutAction;

            var oldHelpInfo = await GetHelpInfo(type, token, cancelationToken);

            if (oldHelpInfo == null)
            {
                methodToExecute = _restService.ExecutePostAction;
            }
            else if (oldHelpInfo.Description != null && oldHelpInfo.Description.Equals(helpInfo?.Description, StringComparison.Ordinal))
            {
                return(true);
            }
            return(await methodToExecute(currentUrl, helpInfo, token, cancelationToken));
        }
Exemplo n.º 3
0
        private TestingObjectProvider()
        {
            Pet = new Pet
            {
                Id           = Guid.NewGuid().ToString(),
                Name         = "TestDog",
                Type         = PetType.Dog,
                Sex          = PetSex.Male,
                Photo        = new byte[10],
                Description  = "Dog that eats tigers",
                Address      = "Found in the jungle",
                Created      = DateTime.Now,
                LastModified = DateTime.Now
            };

            PetsStatus = new PetsStatus()
            {
                Id       = Guid.NewGuid().ToString(),
                IsPublic = true,
                Name     = "testStatusName",
                RGB      = "#fc6dff"
            };

            User = new User
            {
                FirstName   = "Mariusz",
                LastName    = "Wolonatriusz",
                Password    = "******",
                PhoneNumber = "123456789",
                Email       = "*****@*****.**",
                Roles       = new[] { UserType.Volunteer }
            };

            this.Proposal = new Proposal()
            {
                Id           = Guid.NewGuid().ToString(),
                FirstName    = "Mariusz",
                LastName     = "Wolonatriusz",
                PhoneNumber  = "123456789",
                Email        = "*****@*****.**",
                Roles        = new[] { UserType.Volunteer },
                CreationTime = DateTime.Now,
                IsRead       = false
            };

            News = new News
            {
                Id           = Guid.NewGuid().ToString(),
                Title        = "TestNews",
                Published    = DateTime.Now,
                Created      = DateTime.Now,
                LastModified = DateTime.Now,
                Contents     = "Text",
                Photo        = new byte[10],
                Type         = NewsStatus.Released
            };

            Organization = new Organization
            {
                Name    = "Test",
                Address = new Address
                {
                    ApartmentNumber = "45",
                    City            = "TestCity",
                    Country         = "TestCountry",
                    HouseNumber     = "11",
                    PostCode        = "73-220",
                    Street          = "TestStreet"
                },

                BankAccount = new BankAccount
                {
                    BankName = "TestBankName",
                    Number   = "61109010140000071219812874"
                },

                Contact = new Contact
                {
                    Email   = "*****@*****.**",
                    Fax     = "123456789",
                    Phone   = "123456789",
                    Website = "http://testwebsite.com"
                },
            };

            HowToHelpInfo = new HowToHelpInfo()
            {
                Description      = "Deskrypszyn",
                ModificationTime = DateTime.Now
            };

            JwtToken = new JwtToken()
            {
                UserId  = Guid.NewGuid().ToString(),
                Name    = "TestName",
                Surname = "TestSurname",
                Roles   = new string[] { "TestRole1" },
                Email   = "*****@*****.**",
                ExpirationDateSeconds = DateTimeOffset.UtcNow.ToUnixTimeSeconds() + 360,
                Jwt = "Token"
            };

            Login = new Login()
            {
                Email    = "*****@*****.**",
                Password = "******"
            };

            Helper = new Helper()
            {
                Name         = "Mariusz",
                Surname      = "Wolonatriusz",
                PhoneNumber  = "123456789",
                Email        = "*****@*****.**",
                Address      = "Address",
                Category     = HelperCategory.Guardian,
                Created      = DateTime.Now,
                Id           = Guid.NewGuid().ToString(),
                LastModified = DateTime.Now,
                Notes        = "notes"
            };

            Comment = new Comment()
            {
                Contents     = "Bardzo ładny piesek",
                Id           = Guid.NewGuid().ToString(),
                Created      = DateTime.Now,
                LastModified = DateTime.Now,
                State        = CommentState.Active,
                PetUuid      = Pet.Id,
                UserUuid     = User.Id
            };
        }