Exemple #1
0
        public void ShouldGetAllForMember()
        {
            LocationRecordRepository repository = new LocationRecordRepository(context);
            Guid memberId = Guid.NewGuid();

            int initialCount = repository.AllForMember(memberId).Count();

            LocationRecord firstRecord = new LocationRecord()
            {
                ID        = Guid.NewGuid(),
                Timestamp = 1,
                MemberID  = memberId,
                Latitude  = 12.3f
            };

            repository.Add(firstRecord);
            LocationRecord secondRecord = new LocationRecord()
            {
                ID        = Guid.NewGuid(),
                Timestamp = 2,
                MemberID  = memberId,
                Latitude  = 24.4f
            };

            repository.Add(secondRecord);

            ICollection <LocationRecord> records = repository.AllForMember(memberId);
            int afterCount = records.Count();

            Assert.Equal(initialCount + 2, afterCount);
            Assert.NotNull(records.FirstOrDefault(r => r.ID == firstRecord.ID));
            Assert.NotNull(records.FirstOrDefault(r => r.ID == secondRecord.ID));
        }
        public void ShouldDeleteRecord()
        {
            LocationRecordRepository repository = new LocationRecordRepository(context);
            Guid memberId = Guid.NewGuid();

            LocationRecord firstRecord = new LocationRecord()
            {
                ID       = Guid.NewGuid(), Timestamp = 1,
                MemberID = memberId, Latitude = 12.3f
            };

            repository.Add(firstRecord);
            LocationRecord secondRecord = new LocationRecord()
            {
                ID       = Guid.NewGuid(), Timestamp = 2,
                MemberID = memberId, Latitude = 24.4f
            };

            repository.Add(secondRecord);

            int initialCount = repository.AllForMember(memberId).Count();

            repository.Delete(memberId, secondRecord.ID);
            int afterCount = repository.AllForMember(memberId).Count();

            LocationRecord target1 = repository.Get(firstRecord.MemberID, firstRecord.ID);
            LocationRecord target2 = repository.Get(firstRecord.MemberID, secondRecord.ID);

            Assert.Equal(initialCount - 1, afterCount);
            Assert.Equal(target1.ID, firstRecord.ID);
            Assert.NotNull(target1);
            Assert.Null(target2);
        }