Esempio n. 1
0
        public void CreateDTOFromEntity_NullInput()
        {
            //Act
            var revisionDTO = RevisionDTO.CreateDTOFromEntity(entity: null);

            //Assert
            Assert.NotNull(revisionDTO);
        }
Esempio n. 2
0
        public void IsEmpty_AllPropertiesNonEmpty_ExpectFalse()
        {
            //Arrange
            var entity      = new RevisionBuilder(null).Default().Build();
            var revisionDTO = RevisionDTO.CreateDTOFromEntity(entity);

            //Act
            var testResult = revisionDTO.IsEmpty();

            //Assert
            Assert.False(testResult);
        }
Esempio n. 3
0
        public void IsSame_AllPropertiesSame_ExpectTrue()
        {
            //Arrange
            var entity       = new RevisionBuilder(null).Default().Build();
            var revisionDTO1 = RevisionDTO.CreateDTOFromEntity(entity);
            var revisionDTO2 = RevisionDTO.CreateDTOFromEntity(entity);

            //Act
            var testResult = revisionDTO1.IsSame(revisionDTO2);

            //Assert
            Assert.True(testResult);
        }
Esempio n. 4
0
        public void IsSame_AllPropertiesDifferent_ExpectFalse()
        {
            //Arrange
            var entity1      = new RevisionBuilder(null).Default().Build();
            var revisionDTO1 = RevisionDTO.CreateDTOFromEntity(entity1);
            var entity2      = new RevisionBuilder(null).Random().Build();
            var revisionDTO2 = RevisionDTO.CreateDTOFromEntity(entity2);

            //Act
            var testResult = revisionDTO1.IsSame(revisionDTO2);

            //Assert
            Assert.False(testResult);
        }
Esempio n. 5
0
        public void IsSame_MixProperties_ExpectFalse()
        {
            //Arrange
            var entity       = new RevisionBuilder(null).Default().Build();
            var revisionDTO1 = RevisionDTO.CreateDTOFromEntity(entity);

            entity.Title = "IsSame_MixProperties_ExpectFalse";
            var revisionDTO2 = RevisionDTO.CreateDTOFromEntity(entity);

            //Act
            var testResult = revisionDTO1.IsSame(revisionDTO2);

            //Assert
            Assert.False(testResult);
        }
Esempio n. 6
0
        public void Constructor_InputSingleItemList_ExpectCorrectCountAndLatest()
        {
            //Arrange
            var size       = 1;
            var entityList = new RevisionBuilder(null).Default().BuildCollection(size);

            //Act
            var testResult = new RevisionList(entityList);

            //Assert
            var expectResult = RevisionDTO.CreateDTOFromEntity(entityList.Last(), index: size);

            Assert.Equal(size, testResult.Count);
            Assert.True(expectResult.IsSame(testResult.Latest));
            Assert.Equal(size, testResult.Latest.Index);
        }
Esempio n. 7
0
        public void CreateDTOFromEntity_ValidInput()
        {
            //Arrange
            var revisionEntity = new RevisionBuilder(null).Default().Build();

            //Act
            var index       = 1;
            var revisionDTO = RevisionDTO.CreateDTOFromEntity(revisionEntity, index);

            //Assert
            Assert.NotNull(revisionDTO);
            Assert.Equal(revisionEntity.Id, revisionDTO.Id);
            Assert.Equal(revisionEntity.Title, revisionDTO.Title);
            Assert.Equal(revisionEntity.Body, revisionDTO.Body);
            Assert.Equal(revisionEntity.CreatedDateUTC.ToLocalTime().ToString("yyyy-MM-dd"),
                         revisionDTO.CreatedDateLocal);
            Assert.Equal(index, revisionDTO.Index);
        }
Esempio n. 8
0
        public void GetEnumerator_InputSingleItemList_ExpectOneItemInLoop()
        {
            //Arrange
            var size       = 1;
            var entityList = new RevisionBuilder(null).Default().BuildCollection(size);

            //Act
            var testResult = new RevisionList(entityList);

            //Assert
            var expectResult = RevisionDTO.CreateDTOFromEntity(entityList.Last());
            var count        = 1;

            foreach (var item in testResult)
            {
                Assert.False(count > size);
                Assert.True(expectResult.IsSame(item));
                Assert.Equal(count, item.Index);
                count++;
            }
        }
Esempio n. 9
0
        public void GetEnumerator_InputMultipleItemsList_ExpectCorrectItemsInLoop()
        {
            //Arrange
            var size       = 3;
            var entityList = new RevisionBuilder(null).Default().BuildCollection(size);

            //Act
            var testResult = new RevisionList(entityList);

            //Assert
            var expectList = entityList
                             .OrderBy(e => e.CreatedDateUTC)
                             .Select(e => RevisionDTO.CreateDTOFromEntity(e));
            var count = 1;

            foreach (var item in testResult)
            {
                Assert.False(count > size);
                Assert.True(expectList.ElementAt(count - 1).IsSame(item));
                Assert.Equal(count, item.Index);
                count++;
            }
        }