public async Task CommitChangesIsNotExecuted() { var testNamespaces = ReservedNamespaceServiceTestData.GetTestNamespaces(); var existingNamespace = testNamespaces.First(); var testPackageRegistrations = ReservedNamespaceServiceTestData.GetRegistrations(); var existingReg = testPackageRegistrations.First(); var service = new TestableReservedNamespaceService(reservedNamespaces: testNamespaces, packageRegistrations: testPackageRegistrations); await service.AddPackageRegistrationToNamespaceAsync(existingNamespace.Value, existingReg, commitChanges : false); service .MockReservedNamespaceRepository .Verify(x => x.CommitChangesAsync(), Times.Never); Assert.True(existingNamespace.PackageRegistrations.Contains(existingReg)); }
public async Task PackageRegistrationIsAddedWithCommitSuccessfully() { var testNamespaces = ReservedNamespaceServiceTestData.GetTestNamespaces(); var existingNamespace = testNamespaces.First(); var testPackageRegistrations = ReservedNamespaceServiceTestData.GetRegistrations(); var existingReg = testPackageRegistrations.First(); var service = new TestableReservedNamespaceService(reservedNamespaces: testNamespaces, packageRegistrations: testPackageRegistrations); await service.AddPackageRegistrationToNamespaceAsync(existingNamespace.Value, existingReg, commitChanges : true); service .MockReservedNamespaceRepository .Verify(x => x.CommitChangesAsync()); Assert.True(existingNamespace.PackageRegistrations.Contains(existingReg)); }
public async Task NullPackageRegistrationThrowsException() { var service = new TestableReservedNamespaceService(); await Assert.ThrowsAsync <ArgumentNullException>(async() => await service.AddPackageRegistrationToNamespaceAsync("Microsoft.", null)); }
public async Task NonExistentNamespaceThrowsException() { var testNamespaces = ReservedNamespaceServiceTestData.GetTestNamespaces(); var testPackageRegistrations = ReservedNamespaceServiceTestData.GetRegistrations(); var existingReg = testPackageRegistrations.First(); var service = new TestableReservedNamespaceService(reservedNamespaces: testNamespaces, packageRegistrations: testPackageRegistrations); await Assert.ThrowsAsync <InvalidOperationException>(async() => await service.AddPackageRegistrationToNamespaceAsync("Non.Existent.Namespace.", existingReg)); }
public async Task NullNamespaceThrowsException(string value) { var service = new TestableReservedNamespaceService(); await Assert.ThrowsAsync <ArgumentException>(async() => await service.AddPackageRegistrationToNamespaceAsync(value, new PackageRegistration())); }