Ejemplo n.º 1
0
        public async Task AddLicenseAsync_AddsNew_Async()
        {
            var client       = new Mock <KubernetesClient>(MockBehavior.Strict);
            var configClient = new Mock <NamespacedKubernetesClient <V1ConfigMap> >(MockBehavior.Strict);

            client.Setup(c => c.GetClient <V1ConfigMap>()).Returns(configClient.Object);
            configClient.Setup(c => c.TryReadAsync("kaponata-license", default)).ReturnsAsync((V1ConfigMap)null).Verifiable();
            configClient.Setup(c => c.CreateAsync(It.IsAny <V1ConfigMap>(), default)).Returns(Task.FromResult(new V1ConfigMap())).Verifiable();

            var store = new LicenseStore(client.Object, NullLogger <LicenseStore> .Instance);

            var license = new XDocument();

            await store.AddLicenseAsync(license, default).ConfigureAwait(false);

            configClient.Verify();
        }
Ejemplo n.º 2
0
        public async Task AddLicenseAsync_UpdatesExisting_Async()
        {
            var client       = new Mock <KubernetesClient>(MockBehavior.Strict);
            var configClient = new Mock <NamespacedKubernetesClient <V1ConfigMap> >(MockBehavior.Strict);

            client.Setup(c => c.GetClient <V1ConfigMap>()).Returns(configClient.Object);
            var configMap = new V1ConfigMap();

            configClient.Setup(c => c.TryReadAsync("kaponata-license", default)).ReturnsAsync(configMap).Verifiable();
            configClient.Setup(c => c.PatchAsync(configMap, It.IsAny <JsonPatchDocument <V1ConfigMap> >(), default)).ReturnsAsync(configMap).Verifiable();

            var store = new LicenseStore(client.Object, NullLogger <LicenseStore> .Instance);

            var license = new XDocument();

            await store.AddLicenseAsync(license, default).ConfigureAwait(false);

            configClient.Verify();
        }
Ejemplo n.º 3
0
        public async Task AddLicenseAsync_ValidatesArguments_Async()
        {
            var store = new LicenseStore(Mock.Of <KubernetesClient>(), NullLogger <LicenseStore> .Instance);

            await Assert.ThrowsAsync <ArgumentNullException>(() => store.AddLicenseAsync(null, default)).ConfigureAwait(false);
        }