public void GivenValidIdAndNameWhenOnboardingVirtualCuThenTheOnbardingShouldBePossible()
        {
            var onboardVcuService    = new OnboardVcuService(new HttpMessagingService(HttpClient));
            var onboardVcuParameters = new OnboardVcuParameters
            {
                OnboardResponse      = OnboardResponse,
                ApplicationMessageId = MessageIdService.ApplicationMessageId(),
                OnboardingRequests   = new List <OnboardingRequest.Types.EndpointRegistrationDetails>
                {
                    new OnboardingRequest.Types.EndpointRegistrationDetails
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "My first virtual CU..."
                    }
                }
            };

            onboardVcuService.Send(onboardVcuParameters);

            Thread.Sleep(TimeSpan.FromSeconds(5));

            var fetchMessageService = new FetchMessageService(HttpClient);
            var fetch = fetchMessageService.Fetch(OnboardResponse);

            Assert.Single(fetch);

            var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message);

            Assert.Equal(201, decodedMessage.ResponseEnvelope.ResponseCode);
        }
Beispiel #2
0
        public void GivenExistingEndpointIdWhenOffboardingVcuThenTheArShouldReturnErrorMessage()
        {
            var onboardVcuService = new OnboardVcuService(new HttpMessagingService(HttpClient));
            var endpointId        = Guid.NewGuid().ToString();

            var onboardVcuParameters = new OnboardVcuParameters
            {
                OnboardResponse      = OnboardResponse,
                ApplicationMessageId = MessageIdService.ApplicationMessageId(),
                OnboardingRequests   = new List <OnboardingRequest.Types.EndpointRegistrationDetails>
                {
                    new OnboardingRequest.Types.EndpointRegistrationDetails
                    {
                        Id   = endpointId,
                        Name = "My first virtual CU which is deleted directly..."
                    }
                }
            };

            onboardVcuService.Send(onboardVcuParameters);

            Thread.Sleep(TimeSpan.FromSeconds(5));

            var fetchMessageService = new FetchMessageService(HttpClient);
            var fetch = fetchMessageService.Fetch(OnboardResponse);

            Assert.Single(fetch);

            var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message);

            Assert.Equal(201, decodedMessage.ResponseEnvelope.ResponseCode);

            var offboardVcuService =
                new OffboardVcuService(new HttpMessagingService(HttpClient));
            var offboardVcuParameters = new OffboardVcuParameters
            {
                OnboardResponse      = OnboardResponse,
                ApplicationMessageId = MessageIdService.ApplicationMessageId(),
                Endpoints            = new List <string>
                {
                    endpointId
                }
            };

            offboardVcuService.Send(offboardVcuParameters);

            Thread.Sleep(TimeSpan.FromSeconds(5));

            fetch = fetchMessageService.Fetch(OnboardResponse);
            Assert.Single(fetch);

            decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message);
            Assert.Equal(400, decodedMessage.ResponseEnvelope.ResponseCode);
        }