Ejemplo n.º 1
0
        public async Task GetRowsPendingDeletion()
        {
            // Setup:
            // ... Create a session with a proper query and metadata
            EditSession s = await GetBasicSession();

            // ... Add a row deletion
            s.DeleteRow(1);

            // If: I ask for 3 rows from the session, skipping the first, including the updated one
            EditRow[] rows = await s.GetRows(1, 3);

            // Then:
            // ... I should get back 3 rows
            Assert.Equal(3, rows.Length);

            // ... The first row should reflect that there is an update pending
            //     (More in depth testing is done in the RowUpdate class tests)
            var updatedRow = rows[0];

            Assert.Equal(EditRow.EditRowState.DirtyDelete, updatedRow.State);
            Assert.NotEmpty(updatedRow.Cells[0].DisplayValue);

            // ... The other rows should be clean
            for (int i = 1; i < rows.Length; i++)
            {
                Assert.Equal(EditRow.EditRowState.Clean, rows[i].State);
            }
        }
Ejemplo n.º 2
0
        public void DeleteRowNotInitialized()
        {
            // Setup:
            // ... Create a session without initializing
            Mock <IEditMetadataFactory> emf = new Mock <IEditMetadataFactory>();
            EditSession s = new EditSession(emf.Object);

            // If: I ask to delete a row without initializing
            // Then: I should get an exception
            Assert.Throws <InvalidOperationException>(() => s.DeleteRow(0));
        }
Ejemplo n.º 3
0
        public async Task DeleteRowAddFailure()
        {
            // Setup:
            // ... Create a session with a proper query and metadata
            EditSession s = await GetBasicSession();

            // ... Add a mock edit to the edit cache to cause the .TryAdd to fail
            var mockEdit = new Mock <RowEditBase>().Object;

            s.EditCache[0] = mockEdit;

            // If: I delete a row in the session
            // Then:
            // ... An exception should be thrown
            Assert.Throws <InvalidOperationException>(() => s.DeleteRow(0));

            // ... The mock edit should still exist
            Assert.Equal(mockEdit, s.EditCache[0]);
        }