public void CanConvertReleaseCreatedEventToReleaseDto()
        {
            //Arrange
            var mockAdoClient = new Mock <IAdoClient>();
            var fakeRelease   = new ReleaseDto()
            {
                Id = 1, Project = new ProjectDto()
                {
                    Id = new System.Guid("3ededfb7-5b60-49d9-9c47-80bbf8f2dcb1")
                }
            };
            var fakeReleaseEvent = new ReleaseCompletedEvent()
            {
                EventType = ReleaseCompletedEvent.EventIdentifier,
                Resource  = JsonDocument.Parse("{\"release\": {\"id\": 1}, \"project\": {\"id\": \"3ededfb7-5b60-49d9-9c47-80bbf8f2dcb1\"}}").RootElement
            };

            mockAdoClient.Setup(m => m.GetRelease(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(fakeRelease));

            ITypeConverter <AdoEvent, AdoDto> sut = new AdoEventToAdoDtoConverter(mockAdoClient.Object);

            //Act
            var result = sut.Convert(fakeReleaseEvent, null, null) as ReleaseDto;

            //Assert
            Assert.NotNull(sut);
            Assert.NotNull(result);
            Assert.Equal(result.Id, fakeReleaseEvent.Resource?.GetProperty("release").GetProperty("id").GetInt32());
            Assert.Equal(result.Project.Id, fakeReleaseEvent.Resource?.GetProperty("project").GetProperty("id").GetGuid());

            Mock.VerifyAll(mockAdoClient);
        }
Пример #2
0
        public void CanBeConstructed()
        {
            //Arrange
            ReleaseCompletedEvent sut;

            //Act
            sut = new ReleaseCompletedEvent();

            //Assert
            Assert.NotNull(sut);
            Assert.Equal("ms.vss-release.deployment-completed-event", ReleaseCompletedEvent.EventIdentifier);
        }
Пример #3
0
        public void CanBeSerialized()
        {
            //Arrange
            var sut = new ReleaseCompletedEvent()
            {
                Id          = Guid.NewGuid().ToString(),
                EventType   = "MyEventType",
                PublisherId = "MyPublisherId",
                Scope       = "MyScope"
            };

            //Act
            var payload = JsonSerializer.Serialize(sut, new JsonSerializerOptions {
                IgnoreNullValues = true
            });

            //Assert
            Assert.NotNull(JsonDocument.Parse(payload));
        }