public void OwnedNamespacesAllowsPush(string id) { var testNamespaces = ReservedNamespaceServiceTestData.GetTestNamespaces(); var prefix = "microsoft."; var existingNamespace = testNamespaces.FirstOrDefault(rn => rn.Value.Equals(prefix, StringComparison.OrdinalIgnoreCase)); var testUsers = ReservedNamespaceServiceTestData.GetTestUsers(); var firstUser = testUsers.First(); existingNamespace.Owners.Add(firstUser); var service = new TestableReservedNamespaceService(reservedNamespaces: testNamespaces, users: testUsers); var isPushAllowed = service.IsPushAllowed(id, firstUser, out IReadOnlyCollection <ReservedNamespace> matchingNamespaces); Assert.True(isPushAllowed); Assert.NotEmpty(matchingNamespaces); Assert.True(matchingNamespaces.Count() == 1); }
public void NonPrefixNamespaceDoesNotBlockPush(string id) { var testNamespaces = ReservedNamespaceServiceTestData.GetTestNamespaces(); var prefix = "jQuery"; var existingNamespace = testNamespaces.FirstOrDefault(rn => rn.Value.Equals(prefix, StringComparison.OrdinalIgnoreCase)); existingNamespace.IsPrefix = false; var testUsers = ReservedNamespaceServiceTestData.GetTestUsers(); var firstUser = testUsers.First(); var lastUser = testUsers.Last(); existingNamespace.Owners.Add(firstUser); var service = new TestableReservedNamespaceService(reservedNamespaces: testNamespaces, users: testUsers); var isPushAllowed = service.IsPushAllowed(id, lastUser, out IReadOnlyCollection <ReservedNamespace> matchingNamespaces); Assert.Empty(matchingNamespaces); Assert.True(isPushAllowed); }
public void MultipleOwnedNamespacesAreReturnedCorrectly(string id) { var testNamespaces = ReservedNamespaceServiceTestData.GetTestNamespaces(); var prefixes = new List <string> { "microsoft.", "microsoft.aspnet." }; var testUsers = ReservedNamespaceServiceTestData.GetTestUsers(); var firstUser = testUsers.First(); prefixes.ForEach(p => { var existingNamespace = testNamespaces.FirstOrDefault(rn => rn.Value.Equals(p, StringComparison.OrdinalIgnoreCase)); existingNamespace.Owners.Add(firstUser); }); var service = new TestableReservedNamespaceService(reservedNamespaces: testNamespaces, users: testUsers); var isPushAllowed = service.IsPushAllowed(id, firstUser, out IReadOnlyCollection <ReservedNamespace> matchingNamespaces); Assert.True(isPushAllowed); Assert.NotEmpty(matchingNamespaces); Assert.True(matchingNamespaces.Count() == prefixes.Count()); }