Exemple #1
0
        public async Task LookupAsync_ReturnsSoftDeletedRecord_IfIncludeDeletedIsTrue()
        {
            // Arrange
            Person person = TestData.Persons.First();

            person.PartitionKey = person.LastName;
            person.RowKey       = person.FirstName;
            person.CreatedAt    = null;
            person.UpdatedAt    = null;

            await this.manager.InsertAsync(person);

            this.manager.EnableSoftDelete = true;
            bool result = await this.manager.DeleteAsync(person.Id);

            // Act
            this.manager.IncludeDeleted = true;
            CompositeTableKey id       = new CompositeTableKey(person.LastName, person.FirstName);
            Person            lookedup = (await this.manager.LookupAsync(id.ToString())).Queryable.First();

            // Assert
            Assert.Equal(person.Id, lookedup.Id);
            Assert.Equal(true, lookedup.Deleted);
            Assert.Equal(person.FirstName, lookedup.FirstName);
            Assert.Equal(person.LastName, lookedup.LastName);
        }
Exemple #2
0
        public void ToString_GeneratesCorrectTableKey(string[] segments, string expectedKey)
        {
            // Arrange
            CompositeTableKey tableKey = new CompositeTableKey(segments);

            // Act
            string actualTableKey = tableKey.ToString();

            // Assert
            Assert.Equal(expectedKey, actualTableKey);
        }
Exemple #3
0
        public void ToStringAndParse_Roundtrips(string[] expectedSegments)
        {
            // Arrange
            CompositeTableKey tableKey = new CompositeTableKey(expectedSegments);

            // Act
            string actualTableKey = tableKey.ToString();
            IEnumerable <string> actualSubkeys = CompositeTableKey.Parse(actualTableKey).Segments;

            // Assert
            Assert.Equal(expectedSegments, actualSubkeys);
        }
Exemple #4
0
        public async Task LookupAsync_ReturnsData()
        {
            // Arrange
            Collection <Person> persons = TestData.Persons;

            await this.InsertPersons(persons);

            CompositeTableKey id = new CompositeTableKey("Nielsen", "Henrik");

            // Act
            SingleResult <Person> actual = await this.manager.LookupAsync(id.ToString());

            // Assert
            Assert.Equal("Henrik", actual.Queryable.First().FirstName);
        }
 private void VerifyUpdatedKey(CompositeTableKey key, TData data)
 {
     if (data == null || data.PartitionKey != key.Segments[0] || data.RowKey != key.Segments[1])
     {
         string msg = ASResources.TableController_KeyMismatch.FormatForUser("Id", key.ToString(), data.Id);
         HttpResponseMessage badKey = this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, msg);
         throw new HttpResponseException(badKey);
     }
 }
        public void ToStringAndParse_Roundtrips(string[] expectedSegments)
        {
            // Arrange
            CompositeTableKey tableKey = new CompositeTableKey(expectedSegments);

            // Act
            string actualTableKey = tableKey.ToString();
            IEnumerable<string> actualSubkeys = CompositeTableKey.Parse(actualTableKey).Segments;

            // Assert
            Assert.Equal(expectedSegments, actualSubkeys);
        }
        public void ToString_GeneratesCorrectTableKey(string[] segments, string expectedKey)
        {
            // Arrange
            CompositeTableKey tableKey = new CompositeTableKey(segments);

            // Act
            string actualTableKey = tableKey.ToString();

            // Assert
            Assert.Equal(expectedKey, actualTableKey);
        }
Exemple #8
0
        public async Task LookupAsync_DoesNotReturnSoftDeletedRecord_IfIncludeDeletedIsFalse()
        {
            // Arrange
            Person person = TestData.Persons.First();

            person.PartitionKey = person.LastName;
            person.RowKey       = person.FirstName;
            person.CreatedAt    = null;
            person.UpdatedAt    = null;

            await this.manager.InsertAsync(person);

            this.manager.EnableSoftDelete = true;
            bool result = await this.manager.DeleteAsync(person.Id);

            // Act
            this.manager.IncludeDeleted = false;
            CompositeTableKey     id = new CompositeTableKey(person.LastName, person.FirstName);
            HttpResponseException ex = await AssertEx.ThrowsAsync <HttpResponseException>(async() => await this.manager.LookupAsync(id.ToString()));

            Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode);
        }