Пример #1
0
 private void SetMapperConfiguration(IContext o, IMapperConfigurationExpression c)
 {
     c.ConstructServicesUsing(o.GetInstance);
     c.CreateMap <Guid, ShortGuid>().ConvertUsing(g => ShortGuid.Encode(g));
     c.CreateMap <ShortGuid, Guid>().ConvertUsing(sg => sg.ToGuid());
     o.GetAllInstances <Profile>().ForEach(c.AddProfile);
 }
        private void SetListActionViewBags(IProjectPoco projectWithUsers)
        {
            var projectUsers = projectWithUsers.ProjectUsers.Select(p => p.User);

            ViewBag.PId          = ShortGuid.Encode(projectWithUsers.Id);
            ViewBag.ProjectUsers = projectUsers.ToDictionary(p => p.Id, d => d.UserName);
            ViewBag.PriorityList = lookupService.GetAllTaskPriority().ToDictionary(p => p.Id, d => d.Name);
            ViewBag.StatusList   = lookupService.GetAllTaskStatus().ToDictionary(p => p.Id, d => d.Name);
        }
Пример #3
0
        public void EncodeTest1()
        {
            string value    = string.Empty; // TODO: Initialize to an appropriate value
            string expected = string.Empty; // TODO: Initialize to an appropriate value
            string actual;

            actual = ShortGuid.Encode(value);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Пример #4
0
        public void ShortGuidEncodeTest()
        {
            var g = Guid.NewGuid();

            var sg1 = ShortGuid.Encode(g);
            var sg2 = ShortGuid.Encode(g.ToString());

            Assert.AreEqual(sg1, sg2);
            Assert.AreEqual(sg2, sg1);
        }
Пример #5
0
        public void DoTest()
        {
            string shortGuid = ShortGuid.NewGuid();

            output.WriteLine($"shortGuid\t: {shortGuid}");

            string decodedGuid = ShortGuid.Decode(shortGuid).ToString();

            output.WriteLine($"decodedGuid\t: {decodedGuid}");

            Assert.Equal(shortGuid, ShortGuid.Encode(decodedGuid));
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var prop = property.FindPropertyRelative("_value");
            var str  = prop.stringValue;

            if (string.IsNullOrEmpty(str))
            {
                str = ShortGuid.Encode(System.Guid.NewGuid());
                prop.stringValue = str;
            }
            EditorGUI.TextField(position, label, str);
        }
Пример #7
0
        private async Task SetTeamListViewBagAsync(IEnumerable <UserPreviewViewModel> projectUsers, Guid companyId, Guid projectId)
        {
            var optionalUsers = await UserStore.GetUsersAsync(p => p.CompanyId == companyId, null,
                                                              this.ToNavPropertyString(nameof(IUserPoco.ProjectUsers)));

            optionalUsers = optionalUsers.Where(p => p.ProjectUsers.Count(d => d.ProjectId == projectId) == 0).ToList();

            var projectRoles = lookupService.GetAllProjectRoles();

            ViewBag.PId           = ShortGuid.Encode(projectId);
            ViewBag.OptionalUsers = new SelectList(optionalUsers, nameof(IUserPoco.Id), nameof(IUserPoco.UserName));
            ViewBag.ProjectRoles  = new SelectList(projectRoles, nameof(IProjectRolePoco.Id), nameof(IProjectRolePoco.Name));
        }
Пример #8
0
 /// <summary>
 /// Fix quotes for sql query strings
 /// </summary>
 public static ShortGuid ToShortGuid(object obj)
 {
     if (Convert.IsDBNull(obj))
     {
         return(ShortGuid.Empty);
     }
     else if (obj == null)
     {
         return(ShortGuid.Empty);
     }
     else
     {
         return((ShortGuid)ShortGuid.Encode(obj.ToString()));
     }
 }
        public void ToShortGuid_GivenGuid_RetunsShortGuidRepresentationOfGuid()
        {
            var guid = Guid.Parse("7B9DA377-CD4B-431E-BE8E-16693D1B613C");

            var sg = guid.ToShortGuid();

            Assert.Equal("d6Ode0vNHkO-jhZpPRthPA", sg.Value);
            Assert.Equal(sg.Guid, guid);

            Assert.Equal(ShortGuid.Empty.Guid, Guid.Empty);

            var s = ShortGuid.Encode(guid.ToString());
            var g = ShortGuid.Decode(s);

            Assert.Equal(g, guid);

            Assert.True(sg == new ShortGuid(s));

            Assert.Null(ShortGuid.Decode("7-0l0eWeHRnv93947qn9bvSD"));
            Assert.Equal(ShortGuid.Empty.Value, new ShortGuid("7-0l0eWeHRnv93947qn9bvSD").Value);
        }
        void Encode_creates_expected_string()
        {
            string actual = ShortGuid.Encode(SampleGuid);

            Assert.Equal(SampleShortGuidString, actual);
        }
Пример #11
0
        public void mail_message_should_contain_button_href()
        {
            var pictureRes     = Substitute.For <IPictureResizer>();
            var templateReader = Substitute.For <IMailTemplateReader>();

            var content  = @"..\..\Newsletter\TestFiles\3.jpg";
            var resource = new LinkedResource(content);

            const string template = "<html><body><img id=\"newProductImage\" /><a id=\"cancelSubLink\" /><a id=\"goToProduct\"/></body></html>";

            templateReader.GetTemplate(MailTemplateType.Newsletter).Returns(x => template);

            var productId   = Guid.NewGuid();
            var mailMessage = new NewsletterMessage
            {
                To                = new[] { "*****@*****.**" },
                Body              = "",
                From              = "*****@*****.**",
                Subject           = "Subject",
                ProductUrl        = "TestUri",
                ProductId         = productId,
                NewsLetterPicture = new NewsletterPicture
                {
                    LinkedResource = resource
                },
                NewsletterClients = new[]
                {
                    new NewsletterClient()
                    {
                        Email      = "*****@*****.**",
                        Id         = "TestKlient",
                        InsertDate = DateTime.Now
                    },
                }
            };

            var messageFactory = new MailMessageFactory(pictureRes, templateReader);
            var messages       = messageFactory.GetMessages(mailMessage);

            messages.First().Body.Should().Contain($"href=\"www.crochetbyjk.pl/newsletter/{ShortGuid.Encode(productId)}\"");
        }
        private static HtmlNode GetBaseOfNewsletterMessage(string template, NewsletterMessage message)
        {
            var html = new HtmlDocument();

            html.LoadHtml(template);
            var root = html.DocumentNode;

            root.Descendants("img")
            .Single(x => x.Id == "newProductImage")
            .Attributes.Append("src", $"cid:{message.NewsLetterPicture.LinkedResource.ContentId}");
            root.Descendants("a").Single(x => x.Id == "goToProduct").Attributes.Append("href", $"https://www.crochetbyjk.pl/newsletter/{ShortGuid.Encode(message.ProductId)}");
            return(root);
        }
        public void Encode_ShouldEncodeGuid(Guid guid, string expected)
        {
            string shortGuid = ShortGuid.Encode(guid);

            shortGuid.Should().Be(expected);
        }