示例#1
0
        public void Sha1Hash_GetHash_Null_3()
        {
            IHash hashAlgo = new Sha1Hash();

            Action action = () => hashAlgo.GetHash(null as FileInfo);

            action.Should().Throw <ArgumentNullException>();
        }
示例#2
0
        public void Sha1Hash_GetHash_Empty()
        {
            IHash hashAlgo = new Sha1Hash();

            Action action = () => hashAlgo.GetHash(string.Empty);

            action.Should().Throw <ArgumentNullException>();
        }
示例#3
0
        public void Sha1Hash_GetHash_Valid_2()
        {
            IHash hashAlgo = new Sha1Hash();

            HashResult hashResult = hashAlgo.GetHash(Data.ExpectedHashFilePath);

            hashResult.Algorithm.Should().Be(Hashing.ExpectedSha1Algorithm);
            hashResult.Value.Should().Be(Hashing.ExpectedSha1Hash);
        }
示例#4
0
        public void Sha1Hash_GetHash_Valid_1()
        {
            IHash hashAlgo = new Sha1Hash();

            using FileStream fileStream = new(Data.ExpectedHashFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);

            HashResult hashResult = hashAlgo.GetHash(fileStream);

            hashResult.Algorithm.Should().Be(Hashing.ExpectedSha1Algorithm);
            hashResult.Value.Should().Be(Hashing.ExpectedSha1Hash);
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity <Address>()
            .Property(p => p.AddressStr)
            .IsRequired();
            modelBuilder.Entity <Address>()
            .Property(p => p.OpeningHours)
            .IsRequired()
            .HasDefaultValue(nonestr);
            modelBuilder.Entity <Address>()
            .Property(p => p.Latitude)
            .HasDefaultValue(0);
            modelBuilder.Entity <Address>()
            .Property(p => p.Longitude)
            .HasDefaultValue(0);

            modelBuilder.Entity <Roaster>()
            .Property(p => p.Name)
            .IsRequired();
            modelBuilder.Entity <Roaster>()
            .Property(p => p.ContactPersonName)
            .HasDefaultValue("");
            modelBuilder.Entity <Roaster>()
            .Property(p => p.ContactPersonPhone)
            .HasDefaultValue("");
            modelBuilder.Entity <Roaster>()
            .Property(p => p.Description)
            .HasDefaultValue(nonestr);
            modelBuilder.Entity <Roaster>()
            .Property(p => p.ContactEmail)
            .HasDefaultValue(nonestr);
            modelBuilder.Entity <Roaster>()
            .Property(p => p.ContactNumber)
            .IsRequired();
            modelBuilder.Entity <Roaster>()
            .Property(p => p.TelegramProfileLink)
            .HasDefaultValue(nonestr);
            modelBuilder.Entity <Roaster>()
            .Property(p => p.VkProfileLink)
            .HasDefaultValue(nonestr);
            modelBuilder.Entity <Roaster>()
            .Property(p => p.WebSiteLink)
            .HasDefaultValue(nonestr);
            modelBuilder.Entity <Roaster>()
            .Property(p => p.CreationDate)
            .HasDefaultValue(DateTime.UtcNow);
            modelBuilder.Entity <Roaster>()
            .Property(p => p.Priority)
            .HasDefaultValue(0);

            modelBuilder.Entity <Roaster>()
            .HasOne(r => r.Picture)
            .WithOne(p => p.Roaster)
            .HasForeignKey <Picture>(rk => rk.RoasterId);

            modelBuilder.Entity <Roaster>()
            .HasOne(r => r.OfficeAddress)
            .WithMany(a => a.Roasters);

            modelBuilder.Entity <RoasterRequest>()
            .Property(p => p.TagString)
            .HasDefaultValue(nonestr);

            modelBuilder.Entity <RoasterRequest>()
            .OwnsOne(rr => rr.Roaster);

            modelBuilder.Entity <RoasterRequest>()
            .OwnsOne(rr => rr.Address);

            modelBuilder.Entity <RoasterRequest>()
            .HasOne(rr => rr.Picture)
            .WithOne(rrp => rrp.RoasterRequest)
            .HasForeignKey <PictureRequest>(rp => rp.RoasterRequestId);

            modelBuilder.Entity <Tag>()
            .Property(p => p.TagTitle)
            .IsRequired();

            modelBuilder.Entity <User>()
            .Property(p => p.Email)
            .IsRequired();
            modelBuilder.Entity <User>()
            .Property(p => p.Login)
            .IsRequired();
            modelBuilder.Entity <User>()
            .Property(p => p.Password)
            .IsRequired();
            modelBuilder.Entity <User>()
            .Property(p => p.Role)
            .IsRequired();
            // TODO: Разбить условия полей моделей по методам

            modelBuilder.Entity <RoasterTag>()
            .HasKey(rt => new { rt.RoasterId, rt.TagId });
            modelBuilder.Entity <RoasterTag>()
            .HasOne(r => r.Roaster)
            .WithMany(e => e.RoasterTags)
            .HasForeignKey(r => r.RoasterId);
            modelBuilder.Entity <RoasterTag>()
            .HasOne(t => t.Tag)
            .WithMany(e => e.RoasterTags)
            .HasForeignKey(t => t.TagId);

            modelBuilder.Entity <User>()
            .HasData(User.New("admin",
                              "admin",
                              Sha1Hash.GetHash("admin"),
                              "Master"));
        }