public void Int64ShouldBeNumericType() { var edmProperty = this.builder.Build <long>("prop"); var mappingProperty = new MappingProperty(edmProperty); mappingProperty.IsTypeOfNumericKey().Should().BeTrue(); }
public void ConceptualVsStore() { var factory = new SampleGeneratorFactory( CodeFirstGen.OneToMany.Csdl(), CodeFirstGen.OneToMany.Ssdl(), CodeFirstGen.OneToMany.Msdl()); // -- STORE ------------------------------ var storeEntityType = factory.StoreItemCollection.OfType <EntityType>().First(x => x.Name == "Tags"); var storeMappingProperty = new MappingProperty(storeEntityType.Properties.First(x => x.Name == "ID")); var storeTestSubject = new MappingPropertyMatcherHasStoreGeneratedPattern(storeEntityType); storeTestSubject.IsMatch(storeMappingProperty).Should().BeFalse(); // -- CONCEPTUAL ------------------------------ var conceptualEntityType = factory.ConceptualItemCollection.OfType <EntityType>().First(x => x.Name == "Tag"); var conceptualMappingProperty = new MappingProperty(conceptualEntityType.Properties.First(x => x.Name == "ID")); var conceptualTestSubject = new MappingPropertyMatcherHasStoreGeneratedPattern(conceptualEntityType); conceptualTestSubject.IsMatch(conceptualMappingProperty).Should().BeTrue(); conceptualTestSubject.GetStoreGeneratedPattern(conceptualMappingProperty).Should().Be(StoreGeneratedPattern.None); // NOTE: there's a difference! Make sure it is crystal clear!! storeTestSubject.IsMatch(storeMappingProperty).Should().BeFalse(); conceptualTestSubject.IsMatch(conceptualMappingProperty).Should().BeTrue(); }
public void IsRequiredTypeInt32ShouldReturnFalse() { var edmProperty = this.builder.Build <int>("prop"); var mappingProperty = new MappingProperty(edmProperty); var testSubject = new MappingPropertyMatcherIsRequired(); testSubject.IsMatch(mappingProperty).Should().BeFalse(); }
public void IsFixedLength() { var edmProperty = this.builder.BuildString("prop", false, true); var mappingProperty = new MappingProperty(edmProperty); mappingProperty.IsTypeOfString().Should().BeTrue(); mappingProperty.HasFacet(DbProviderManifest.FixedLengthFacetName).Should().BeTrue(); mappingProperty.GetFacetValue <bool>(DbProviderManifest.FixedLengthFacetName).Should().BeTrue(); }
private T GetPropertyValue <T>(MappingProperty property, ref T field) { if (!this.propertiesSet[(int)property]) { throw new InvalidOperationException(string.Format(Resources.Culture, Resources.MappingDestination_GetPropertyValue_PropertyNotSet, property)); } return(field); }
public void IsRowVersionShouldReturnFalse() { var edmProperty = this.builder.BuildBinary("prop", false, 8); var mappingProperty = new MappingProperty(edmProperty); var testSubject = new MappingPropertyMatcherIsRowVersion(); testSubject.IsMatch(mappingProperty).Should().BeFalse(); }
public void UnboundedStringShouldNotHaveMaxLength() { var edmProperty = this.builder.BuildString("prop", false, false); var mappingProperty = new MappingProperty(edmProperty); var testSubject = new MappingPropertyMatcherMaxLength(); testSubject.IsMatch(mappingProperty).Should().BeFalse(); }
public void IsUnicodeTypeStringShouldReturnFalse() { var edmProperty = this.builder.BuildString("prop", false, false); var mappingProperty = new MappingProperty(edmProperty); var testSubject = new MappingPropertyMatcherIsUnicode(); testSubject.IsMatch(mappingProperty).Should().BeFalse(); }
public void IsStoreGeneratedIdenittyPatternShouldBeTrue() { var edmProperty = this.builder.Build <int>("prop"); edmProperty.StoreGeneratedPattern = System.Data.Entity.Core.Metadata.Edm.StoreGeneratedPattern.Identity; var mappingProperty = new MappingProperty(edmProperty); mappingProperty.IsStoreGeneratedIdentity.Should().BeTrue(); }
public void MaxLengthStringShouldHaveMaxLength() { var edmProperty = this.builder.BuildString("prop", false, false, 128); var mappingProperty = new MappingProperty(edmProperty); var testSubject = new MappingPropertyMatcherMaxLength(); testSubject.IsMatch(mappingProperty).Should().BeTrue(); testSubject.GetMaxLength(mappingProperty).Should().Be(128); }
public void IsFixedLengthStringShouldBeFalse() { var edmProperty = this.builder .BuildString("prop", false, false); var mappingProperty = new MappingProperty(edmProperty); var testSubject = new MappingPropertyMatcherIsFixedLength(); testSubject.IsMatch(mappingProperty).Should().BeFalse(); }
public void IsRowVersionShouldReturnTrue() { var edmProperty = this.builder.BuildBinary("prop", true, 8); edmProperty.StoreGeneratedPattern = StoreGeneratedPattern.Computed; var mappingProperty = new MappingProperty(edmProperty); var testSubject = new MappingPropertyMatcherIsRowVersion(); testSubject.IsMatch(mappingProperty).Should().BeTrue(); }
public void MaxLengthBinary() { var edmProperty = this.builder.BuildBinary("prop", false, 100); var mappingProperty = new MappingProperty(edmProperty); mappingProperty.IsTypeOfByteArray().Should().BeTrue(); mappingProperty.HasFacet(DbProviderManifest.FixedLengthFacetName).Should().BeTrue(); mappingProperty.GetFacetValue <bool>(DbProviderManifest.FixedLengthFacetName).Should().BeFalse(); mappingProperty.HasFacet(DbProviderManifest.MaxLengthFacetName).Should().BeTrue(); mappingProperty.GetFacetValue <int>(DbProviderManifest.MaxLengthFacetName).Should().Be(100); }
public void IsRequiredTypeStringShouldReturnTrue() { var edmProperty = this.builder .BuildString("prop", false, false); edmProperty.Nullable = false; var mappingProperty = new MappingProperty(edmProperty); var testSubject = new MappingPropertyMatcherIsRequired(); testSubject.IsMatch(mappingProperty).Should().BeTrue(); }
public void Required() { var edmProperty = this.builder.BuildString("prop", false, false); edmProperty.Nullable = false; var mappingProperty = new MappingProperty(edmProperty); mappingProperty.IsNullable.Should().BeFalse(); mappingProperty.GetClrEquivalentType().Should().Be(typeof(string)); mappingProperty.IsTypeOfString().Should().BeTrue(); mappingProperty.IsNullable.Should().BeFalse(); }
public void NonKeyMemberWithIdentityShouldHaveStoreGeneratedIdentity() { var entityType = this.builder .Name("My.Table") .WithProperty <int>("ID", x => x.StoreGeneratedPattern = StoreGeneratedPattern.Identity) .Build(); var mappingProperty = new MappingProperty(entityType.Properties.Single()); var testSubject = new MappingPropertyMatcherHasStoreGeneratedPattern(entityType); testSubject.IsMatch(mappingProperty).Should().BeTrue(); testSubject.GetStoreGeneratedPattern(mappingProperty).Should().Be(StoreGeneratedPattern.Identity); }
public void NumericKeyShouldNotMatch() { var entityType = this.builder .Name("My.Table") .WithProperty <int>("ID", x => x.StoreGeneratedPattern = StoreGeneratedPattern.Identity) .WithKeys("ID") .Build(); var mappingProperty = new MappingProperty(entityType.Properties.Single()); var testSubject = new MappingPropertyMatcherHasStoreGeneratedPattern(entityType); testSubject.IsMatch(mappingProperty).Should().BeFalse(); }
public vmUser Authenticate(string username, string password) { vmUser _user = new vmUser(); var user = db.SecUsers.SingleOrDefault(x => x.UserName == username && x.Password == password); // return null if user not found if (user == null) { return(null); } // JWT Implementation var ClaimData = new[] { new Claim(ClaimTypes.Name, username), new Claim(ClaimTypes.Role, "admin") }; var _key = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(_appSettings.Secret)); var SignInCred = new SigningCredentials(_key, SecurityAlgorithms.HmacSha256Signature); var _token = new JwtSecurityToken( issuer: "localhost:5001", audience: "localhost:5001", expires: DateTime.Now.AddMinutes(5), claims: ClaimData, signingCredentials: SignInCred ); var Token = new JwtSecurityTokenHandler().WriteToken(_token); user.Token = Token; // tokenHandler.WriteToken(token); user.TokenExpireOn = DateTime.Now.AddMinutes(5); db.SecUsers.Update(user); db.SaveChanges(); user.Password = null; MappingProperty.Map(_user, user); var userRoles = db.SecUserRoles.Where(x => x.SecUserId == user.SecUserId).Select(x => x.SecRoleId).ToList(); var userRolePermissions = db.SecRolePermissions.Where(x => userRoles.Contains(x.SecRoleId)).Select(x => x.SecPermissionId).ToList(); var userPermissions = db.SecPermissions.Where(x => userRolePermissions.Contains(x.SecPermissionId)).ToList(); _user.permissions = userPermissions; _user.RoleName = db.SecRoles.Where(x => x.SecRoleId == userRoles[0]).FirstOrDefault().RoleName; return(_user); }
public void CompositeKeyShouldHaveStoreGeneratedNone() { var entityType = this.builder .Name("My.Table") .WithProperty <int>("ID", x => x.StoreGeneratedPattern = StoreGeneratedPattern.None) .WithProperty <string>("Name", x => x.StoreGeneratedPattern = StoreGeneratedPattern.None) .WithKeys("ID", "Name") .Build(); var testSubject = new MappingPropertyMatcherHasStoreGeneratedPattern(entityType); var mappingProperty1 = new MappingProperty(entityType.Properties.First(x => x.Name == "ID")); testSubject.IsMatch(mappingProperty1).Should().BeTrue(); testSubject.GetStoreGeneratedPattern(mappingProperty1).Should().Be(StoreGeneratedPattern.None); var mappingProperty2 = new MappingProperty(entityType.Properties.First(x => x.Name == "Name")); testSubject.IsMatch(mappingProperty2).Should().BeFalse(); }
public bool IsMatch(MappingProperty mappingProperty) { return ((mappingProperty.IsTypeOfString() || mappingProperty.IsTypeOfByteArray()) && !mappingProperty.IsNullable); }
public bool IsPropertySet(MappingProperty property) { return(this.IsPropertySet((int)property)); }
// ReSharper disable once RedundantAssignment private void SetPropertyValue <T>(MappingProperty property, T value, ref T field) { field = value; this.propertiesSet[(int)property] = true; }