Beispiel #1
0
 private void CheckFieldsEquality(EntityPair <TrainingProviderAuthor, PluralsightAuthor> authorPair)
 {
     Assert.Equal(authorPair.ParseModelEntity.Id, authorPair.DbEntity.AuthorId);
     Assert.Equal(authorPair.ParseModelEntity.FullName, authorPair.DbEntity.FullName);
     Assert.Equal(authorPair.ParseModelEntity.SiteUrl, authorPair.DbEntity.SiteUrl);
     Assert.Equal(authorPair.ParseModelEntity.UrlName, authorPair.DbEntity.UrlName);
 }
        public void Execute(int i)
        {
            EntityPair pair = _entityPairs[i];

            _lines[i] = new Line {
                P1 = _positions[pair.E1].Value,
                P2 = _positions[pair.E2].Value
            };
        }
Beispiel #3
0
        /// <exception cref="InvalidOperationException"><paramref name="coursePair"/>.ParseModelEntity.Category.Id equal <value>0</value>.</exception>
        protected override void AssignCategoryIdToDbEntity(EntityPair <Course, PluralsightCourse> coursePair)
        {
            if (coursePair.ParseModelEntity.Category.Id == 0)
            {
                throw new InvalidOperationException(Resources.InvalidOperation_CategoryIdMustBeSetOnTheCourse);
            }


            coursePair.DbEntity.CategoryId = coursePair.ParseModelEntity.Category.Id;
        }
Beispiel #4
0
        public static bool TryInteract <T, Y>
            (this EntityPair pair, ref int index, ComponentDataFromEntity <T> getterA, ComponentDataFromEntity <Y> getterB, out Entity a, out Entity b)
            where T : struct, IComponentData where Y : struct, IComponentData
        {
            bool switched = index > 0;

            a = switched ? pair.EntityB : pair.EntityA;
            b = switched ? pair.EntityA : pair.EntityB;

            return(index++ < 2 && getterA.Exists(a) & getterB.Exists(b));
        }
Beispiel #5
0
        /// <exception cref="InvalidOperationException"><paramref name="coursePair"/>.ParseModelEntity.Category.Id equal <value>0</value>.</exception>
        protected override bool IsMovedToAnotherCategory(EntityPair <Course, PluralsightCourse> coursePair)
        {
            if (coursePair.ParseModelEntity.Category.Id == 0)
            {
                throw new InvalidOperationException(Resources.InvalidOperation_CategoryIdMustBeSetOnTheCourse);
            }


            var isMovedToAnotherCategory = coursePair.DbEntity.CategoryId != coursePair.ParseModelEntity.Category.Id;

            return(isMovedToAnotherCategory);
        }
        public void Execute(int index)
        {
            EntityPair entityPair = _springEntityPairs[index];
            Line       line       = _springLines[index];
            Elasticity elasticity = _springElasticities[index];

            float3 dist    = (line.P2 - line.P1);
            float  distMag = math.length(dist);
            float  refDist = elasticity.ReferenceLength;

            if (distMag > refDist)
            {
                float3 force = dist * (1 - refDist / distMag) * elasticity.YoungModulus;
                _hashMap.Add(entityPair.E1, force);
                _hashMap.Add(entityPair.E2, -force);
            }
        }
Beispiel #7
0
 public StatefulTriggerEvent(Entity entityA, Entity entityB, int bodyIndexA, int bodyIndexB,
                             ColliderKey colliderKeyA, ColliderKey colliderKeyB)
 {
     Entities = new EntityPair
     {
         EntityA = entityA,
         EntityB = entityB
     };
     BodyIndices = new BodyIndexPair
     {
         BodyIndexA = bodyIndexA,
         BodyIndexB = bodyIndexB
     };
     ColliderKeys = new ColliderKeyPair
     {
         ColliderKeyA = colliderKeyA,
         ColliderKeyB = colliderKeyB
     };
     State = default;
 }
 public StatefulCollisionEvent(Entity entityA, Entity entityB, int bodyIndexA, int bodyIndexB,
                               ColliderKey colliderKeyA, ColliderKey colliderKeyB, float3 normal)
 {
     Entities = new EntityPair
     {
         EntityA = entityA,
         EntityB = entityB
     };
     BodyIndices = new BodyIndexPair
     {
         BodyIndexA = bodyIndexA,
         BodyIndexB = bodyIndexB
     };
     ColliderKeys = new ColliderKeyPair
     {
         ColliderKeyA = colliderKeyA,
         ColliderKeyB = colliderKeyB
     };
     Normal           = normal;
     CollidingState   = default;
     CollisionDetails = default;
 }
Beispiel #9
0
 public bool Equals(EntityPair other) => Owner == other.Owner && Referent == other.Referent;
 private void CheckFieldsEquality(EntityPair<TrainingProviderAuthor, PluralsightAuthor> authorPair)
 {
    Assert.Equal(authorPair.ParseModelEntity.Id, authorPair.DbEntity.AuthorId);
    Assert.Equal(authorPair.ParseModelEntity.FullName, authorPair.DbEntity.FullName);
    Assert.Equal(authorPair.ParseModelEntity.SiteUrl, authorPair.DbEntity.SiteUrl);
    Assert.Equal(authorPair.ParseModelEntity.UrlName, authorPair.DbEntity.UrlName);
 }
Beispiel #11
0
        public async Task Should_ReturnAuthorsChanges()
        {
            // Arrange
            var existingAuthors = new List <TrainingProviderAuthor>
            {
                new TrainingProviderAuthor
                {
                    TrainingProviderId = TrainingProviderId,
                    AuthorId           = 1,
                    FullName           = "n s1",
                    SiteUrl            = "http://example.com/n-s1",
                    UrlName            = "n-s1"
                },
                new TrainingProviderAuthor
                {
                    TrainingProviderId = TrainingProviderId,
                    AuthorId           = 2,
                    FullName           = "n s2",
                    SiteUrl            = "http://example.com/n-s2",
                    UrlName            = "n-s2"
                },
                new TrainingProviderAuthor
                {
                    TrainingProviderId = TrainingProviderId,
                    AuthorId           = 3,
                    FullName           = "n s3",
                    SiteUrl            = "http://example.com/n-s3",
                    UrlName            = "n-s3"
                }
            };

            var processingAuthorsDictionary = new List <PluralsightAuthor>
            {
                new PluralsightAuthor
                {
                    FullName = "n s1",
                    SiteUrl  = "http://example.com/n-s1",
                    UrlName  = "n-s1"
                },
                new PluralsightAuthor
                {
                    FullName = "n s2",
                    SiteUrl  = "http://example.com/n-s2modified",
                    UrlName  = "n-s2"
                },
                new PluralsightAuthor
                {
                    FullName = "n s4",
                    SiteUrl  = "http://example.com/n-s4",
                    UrlName  = "n-s4"
                }
            }.ToDictionary(x => x, x => x, UrlNameNaturalKeyEqualityComparer <IAuthorUrlNameNaturalKey> .Instance);


            var parseResultMock = new Mock <IUpdateContentParseResult <PluralsightCategory, PluralsightCourse, PluralsightAuthor> >();

            parseResultMock.SetupGet(x => x.AuthorsParseResult.AuthorsExceptWhoseUrlNullContainer)
            .Returns(processingAuthorsDictionary);

            var dataServiceMock = new Mock <IPluralsightDataService>();

            var dataServiceAuthorResultFake = new Author();

            dataServiceMock.Setup(x => x.GetAuthorAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(dataServiceAuthorResultFake));


            var sut = new PluralsightChangesProcessor(parseResultMock.Object, dataServiceMock.Object);

            // Act
            var result = await sut.GetAuthorsChangesAsync(TrainingProviderId, existingAuthors, AuthorsChangesDetector);

            // Assert

            // deleted authors
            Assert.Equal(1, result.DeletedEntities.Count);
            Assert.Same(existingAuthors[2], result.DeletedEntities.Single(x => x.AuthorId == existingAuthors[2].AuthorId));

            // modified authors
            Assert.Equal(1, result.ModifiedEntities.Count);

            var existingAuthor   = existingAuthors[1];
            var processingAuthor = processingAuthorsDictionary.Values.Single(x => x.UrlName == existingAuthor.UrlName);
            EntityPair <TrainingProviderAuthor, PluralsightAuthor> authorPair = result.ModifiedEntities.Single(x => x.DbEntity.AuthorId == existingAuthor.AuthorId);

            Assert.Same(existingAuthor, authorPair.DbEntity);
            Assert.Same(processingAuthor, authorPair.ParseModelEntity);
            Assert.Equal(authorPair.DbEntity.AuthorId, authorPair.ParseModelEntity.Id);

            // unmodified authors
            Assert.Equal(1, result.UnmodifiedEntities.Count);

            existingAuthor   = existingAuthors[0];
            processingAuthor = processingAuthorsDictionary.Values.Single(x => x.UrlName == existingAuthor.UrlName);
            authorPair       = result.UnmodifiedEntities.Single(x => x.DbEntity.AuthorId == existingAuthor.AuthorId);

            Assert.Same(existingAuthor, authorPair.DbEntity);
            Assert.Same(processingAuthor, authorPair.ParseModelEntity);
            Assert.Equal(authorPair.DbEntity.AuthorId, authorPair.ParseModelEntity.Id);

            // new authors
            Assert.Equal(1, result.NewEntities.Count);

            processingAuthor = processingAuthorsDictionary.Values.ToList()[2];
            authorPair       = result.NewEntities.Single(x => x.ParseModelEntity.UrlName == processingAuthor.UrlName);

            Assert.Same(processingAuthor, authorPair.ParseModelEntity);
            Assert.Same(authorPair.DbEntity.Author, dataServiceAuthorResultFake);

            CheckFieldsEquality(authorPair);
        }