예제 #1
0
            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);
            }
예제 #2
0
            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);
            }
예제 #3
0
            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());
            }