public void StartTenantCollection() { var id = Guid.NewGuid(); var id2 = Guid.NewGuid(); var tenant1 = new TenantDefault(id, "Tenant 1"); var tenant2 = new TenantDefault(id, "Tenant 2"); var tenant3 = new TenantDefault(id2, "Tenant 3"); var secrets2 = new Dictionary <string, string>() { { "Secret2", "Value 1" } }; var tenantSecret2 = new TenantSecret <Guid, dynamic>(id2, secrets: secrets2); var claims = new Dictionary <string, string>() { { "Claims1", "Value 1" } }; var tenantClaims = new TenantClaims <Guid, dynamic>(id, claims: claims); var collection = new TenantCollection(new[] { tenant1, tenant2, tenant3 }); Assert.AreEqual(2, collection.Count); var itens = new ITenant <Guid>[] { tenant1, tenant2, tenant3, tenantClaims, _secretFirstTenant, tenantSecret2, null }; var collection2 = new TenantCollection(); collection2.Add(itens); Assert.AreEqual(3, collection2.Count); Assert.ThrowsException <ArgumentNullException>(() => collection2.Add((IEnumerable <ITenant <Guid> >)null)); }
public void CheckIfTenantSecretAndTenantClaimsAreNotEquals_ExpectedTenantEqualityComparerResultTrue() { var comparer = new TenantEqualityComparer <Guid, Dictionary <string, object>, Dictionary <string, object> >(); var tenant = new TenantDefault(_secretFirstTenant); Assert.IsFalse(comparer.Equals(tenant, _secretSecondTenant)); }
public void CheckIfTenantSecretAndTenantClaimsAreEquals() { var comparer = new TenantEqualityComparer <Guid>(); var tenant = new TenantDefault(_secretFirstTenant); var tenant1 = new TenantDefault(_claimsFirstTenant); Assert.IsTrue(comparer.Equals(tenant, tenant1)); }
public void AddTenantAndMergeTenantSecret() { var tenant1 = new TenantDefault(_firstTenantId, "Tenant 1"); var tenant = new TenantCollection(); tenant.Add(tenant1); tenant.Add(_secretFirstTenant); Assert.AreEqual(tenant.Count, 1); }
public void InitializeTenantDefaultWithNewValues() { const string tenantName = " Tenant 01 "; Guid id = Guid.NewGuid(); var tenant = new TenantDefault(id, tenantName); Assert.AreEqual(tenantName.Trim(), tenant.Name, "The object name can't start or finished with space"); Assert.IsTrue(tenant.IsEnabled, "por padrão, um tenant deve iniciar ativo"); Assert.IsNull(tenant.Secrets, "Não foi definido um secrets para esse tenant"); Assert.IsNull(tenant.Claims, "Não foi definido um claims para esse tenant"); }
public void AddTenantAndDistinctTenantSecret() { var tenant1 = new TenantDefault(_firstTenantId, "Tenant 1"); var tenant = new TenantCollection(); tenant.Add(tenant1); tenant.Add(_secretSecondTenant); Assert.AreEqual(tenant.Count, 2); //tenantSecret. }
public void AddTenantAndMergeTenantClaimsAndSecret() { var tenant1 = new TenantDefault(_firstTenantId, "Tenant 1"); var tenant = new TenantCollection(); tenant.Add(tenant1); tenant.Add(_claimsFirstTenant); tenant.Add(new[] { _secretFirstTenant }); Console.WriteLine(tenant.ToString()); Assert.AreEqual(tenant.Count, 1); }
public void AddDuplicatesTenants() { var id = Guid.NewGuid(); var tenant1 = new TenantDefault(id, "Tenant 1"); var tenant2 = new TenantDefault(id, "Tenant 2"); var tenant = new TenantCollection(); tenant.Add(tenant1); tenant.Add(tenant2); tenant.Add((TenantDefault)null); Assert.AreEqual(tenant.Count, 1, "A clase permitiu adicionar duas instancias iguais"); }
public void InitializeTenantDefault() { var tenant = new TenantDefault(); Assert.AreEqual(tenant.Id, Guid.Empty, "O identificador padrão do tenant não corresponde ao valor padrão"); Assert.AreEqual(tenant.Name, string.Empty, "O nome padrão do tenant não corresponde uma string vazia"); Assert.IsTrue(tenant.IsEnabled, "O tenant padrão não está iniciando ativa"); Assert.AreEqual(tenant.Secrets, null, "Os segredos deveriam iniciar null"); Assert.AreEqual(tenant.Claims, null, "As claims deveriam iniciar null"); }
public void InitializeTenantWithAllProperties() { var claims = new Dictionary <string, object>() { { "Claims 01", "Value 01" } }; var secrets = new Dictionary <string, object>() { { "secrets 01", "Value 01" } }; var tenannt = new TenantDefault(Guid.NewGuid(), "New Tenant 01", claims, secrets); Assert.AreEqual(claims, tenannt.Claims); Assert.AreEqual(secrets, tenannt.Secrets); }
public void AddTenantAndMergeTenantClaims() { var tenant1 = new TenantDefault(_firstTenantId, "Tenant 1"); var tenant = new TenantCollection(); tenant.Add(tenant1); tenant.Add(new[] { _claimsFirstTenant }); var tenantk = tenant.FirstOrDefault(_firstTenantId); Assert.IsNotNull(tenantk); Assert.AreEqual(tenant.Count, 1); Assert.IsTrue(tenantk.Claims.ContainsKey("Claims1")); }
public void AddNewTenants() { var tenant1 = new TenantDefault(Guid.NewGuid(), "Tenant 1"); var tenant2 = new TenantDefault(Guid.NewGuid(), "Tenant 2"); var tenant = new TenantCollection(); int current = 0; Assert.AreEqual(tenant.Count, current, "Ao instanciar uma coleção ela iniciou com itens carregados"); current++; tenant.Add(tenant1); Assert.AreEqual(tenant.Count, current, "Após adicionar um item na coleção a lista de itens não foi alterada"); tenant.Add(tenant2); current++; Assert.AreEqual(tenant.Count, current, "Após adicionar um segundo item na coleção a lista de itens não foi alterada"); }
public void AreEquals() { var tenant1 = new TenantDefault <int>(1, "Tenant 1"); var tenant2 = new Tenant <int, string, DateTime>(1, "Tenant 2") { Secrets = DateTime.Now, Claims = "Claims 01" }; var tenant3 = new Tenant <int, DateTime, string>(1, "Tenant 3") { Claims = DateTime.Now, Secrets = "Secrets 01" }; var list = new ITenant <int>[] { tenant1, tenant2, tenant3 }.ToHashSet(new TenantEqualityComparer <int>()); Assert.AreEqual(1, list.Count); var list2 = new ITenant <int>[] { tenant1, tenant2, tenant3 }.ToHashSet(new TenantEqualityComparer <int, string, DateTime>()); Assert.AreEqual(3, list2.Count); }
public void MergeTenantWithSecretAndCheckAllInstancies_ExpectedAllInstanceRelated() { var id = _secretFirstTenant.Id; var tenant1 = new TenantDefault(id, "Tenant 1"); var tenant2 = new TenantDefault(id, "Tenant 1 - One"); var tenant3 = new TenantDefault(_secretSecondTenant.Id, "Tenant 3"); var collection2 = new TenantCollection(); var itens = new ITenant <Guid>[] { tenant1, tenant2, tenant3, _secretSecondTenant, _secretFirstTenant }; collection2.Add(itens); Assert.IsTrue(tenant3.Secrets?.Equals(_secretSecondTenant.Secrets) == true); Assert.AreEqual(2, collection2.Count); }