コード例 #1
0
        protected TestableCustomResource CreateCustomResource(string uid = "1", string ns = null, long generation = 1L, bool withFinalizer = true, DateTime?deletionTimeStamp = null)
        {
            var resource = new TestableCustomResource();

            if (withFinalizer)
            {
                resource.Metadata.EnsureFinalizers().Add(CustomResourceDefinitionAttribute.DEFAULT_FINALIZER);
            }

            if (ns != null)
            {
                resource.Metadata.NamespaceProperty = ns;
            }
            resource.Metadata.Uid = uid;
            resource.Metadata.DeletionTimestamp = deletionTimeStamp;
            resource.Metadata.Generation        = generation;

            resource.Spec   = new TestableCustomResource.TestableSpec();
            resource.Status = new TestableCustomResource.TestableStatus();

            return(resource);
        }
コード例 #2
0
        private void VerifyReplaceIsCalled(object input, out TestableCustomResource updatedResource)
        {
            // Get the resource that has been passed to the API
            var resource = _clientMock.Invocations[0].Arguments[0] as TestableCustomResource;

            // Verify the API has been called once
            _clientMock.Verify(x => x.ReplaceNamespacedCustomObjectWithHttpMessagesAsync
                               (
                                   input,
                                   "group",
                                   "v1",
                                   "ns1",
                                   "resources",
                                   "resource1",
                                   null,
                                   default(System.Threading.CancellationToken)
                               ), Times.Once);

            updatedResource = resource;

            _clientMock.VerifyNoOtherCalls();
        }