public void Get_By_Id_Method_Returns_Just_Added_Item() { var storage = new SqlReminderStorage(_connectionString); DateTimeOffset expectedDate = DateTimeOffset.Now; string expectedContactId = "TEST_CONTACT_ID"; string expectedMessage = "TEST_MESSAGE_TEXT"; ReminderItemStatus expectedStatus = ReminderItemStatus.Awaiting; Guid id = storage.Add(new ReminderItemRestricted { ContactId = expectedContactId, Date = expectedDate, Message = expectedMessage, Status = expectedStatus }); Assert.AreNotEqual(Guid.Empty, id); var actualItem = storage.Get(id); Assert.IsNotNull(actualItem); Assert.AreEqual(id, actualItem.Id); Assert.AreEqual(expectedDate, actualItem.Date); Assert.AreEqual(expectedContactId, actualItem.ContactId); Assert.AreEqual(expectedMessage, actualItem.Message); Assert.AreEqual(expectedStatus, actualItem.Status); }
public void Remove_Method_Returns_True_When_Item_Deleted() { var storage = new SqlReminderStorage(_connectionString); var actual = storage.Remove(new Guid("00000000-0000-0000-0000-111111111111")); Assert.IsTrue(actual); }
public void Delete_Property_Returns_0_If_Reminder_Was_NOT_Deleted() { var storage = new SqlReminderStorage(_connectionString); var isDeleted = storage.Remove(Guid.Parse("00000000-0000-0000-0000-123456789000")); Assert.IsFalse(isDeleted); }
public void Get_By_Status_2_Returns_1_Reminder() { var storage = new SqlReminderStorage(_connectionString); var reminders = storage.Get(ReminderItemStatus.Sent); Assert.AreEqual(1, reminders.Count); }
public void Method_Remove_ReminderItem_By_Id() { var storage = new SqlReminderStorage(_connectionString); var actual = storage.Remove(Guid.Parse("00000000-0000-0000-0000-222222222222")); Assert.IsTrue(actual); }
public void Delete_Property_Returns_1_If_Reminder_Was_Deleted() { var storage = new SqlReminderStorage(_connectionString); var isDeleted = storage.Remove(Guid.Parse("00000000-0000-0000-0000-111111111111")); Assert.IsTrue(isDeleted); }
public void Get_By_Id_Method_Returns_Null_If_Not_Found() { var storage = new SqlReminderStorage(_connectionString); var actual = storage.Get(Guid.Empty); Assert.IsNull(actual); }
public void Property_Count_Returns_8_For_Initial_Data_Set() { var storage = new SqlReminderStorage(_connectionString); int actual = storage.Count; Assert.AreEqual(3, actual); }
public void Remove_Method_Returns_False_When_Item_Not_Found() { var storage = new SqlReminderStorage(_connectionString); var actual = storage.Remove(Guid.Empty); Assert.IsFalse(actual); }
public void Get_Method_With_Count_And_Start_Position_Returns_Limited_Number_Of_Reminders() { var storage = new SqlReminderStorage(_connectionString); var actual = storage.Get(3, 2); Assert.IsNotNull(actual); Assert.AreEqual(3, actual.Count); }
public void Get_Method_Without_Parameters_Returns_All_Reminders() { var storage = new SqlReminderStorage(_connectionString); var actual = storage.Get(); Assert.IsNotNull(actual); Assert.AreEqual(8, actual.Count); }
public void Method_Add_return() { var storage = new SqlReminderStorage(_connectionString); Guid actual = storage.Add(new Core.ReminderItemRestricted()) { } Assert.AreEqual(Guid.Empty, actual); }
public void Method_Delete() { var storage = new SqlReminderStorage(_connectionString); storage.Remove(Guid.Parse("00000000-0000-0000-0000-333333333333")); int actual = storage.Count; Assert.AreEqual(2, actual); }
public void Property_Remove_Method() { var storage = new SqlReminderStorage(_connectionString); Guid id = new Guid("00000000-0000-0000-0000-111111111111"); bool result = storage.Remove(id); Assert.AreEqual(true, result); }
public void Method_Update_Status_By_Guid() { var storage = new SqlReminderStorage(_connectionString); storage.UpdateStatus(Guid.Parse("00000000-0000-0000-0000-444444444444"), ReminderItemStatus.Ready); var actualItemReady = storage.Get(ReminderItemStatus.Ready); var expectedItemReady = 1; Assert.AreEqual(expectedItemReady, actualItemReady.Count); }
public void Method_Get_List_Reminders_By_Status() { var storage = new SqlReminderStorage(_connectionString); int expectedCountAwaiting = 2; var actualItemAwaiting = storage.Get(ReminderItemStatus.Awaiting); Assert.AreEqual(expectedCountAwaiting, actualItemAwaiting.Count); }
public void Remove_By_Id_Method_Returns_True_When_Found_And_Removed() { var storage = new SqlReminderStorage(_connectionString); Guid id = Guid.Parse("00000000-0000-0000-0000-111111111111"); var actual = storage.Remove(id); Assert.IsTrue(actual); var removedItem = storage.Get(id); Assert.IsNull(removedItem); }
public void Update_Status_By_Id_Updates_Status() { var storage = new SqlReminderStorage(_connectionString); Guid id = new Guid("00000000-0000-0000-0000-111111111111"); storage.UpdateStatus( id, ReminderItemStatus.Ready); var reminder = storage.Get(id); Assert.AreEqual(ReminderItemStatus.Ready, reminder.Status); }
public void Method_Add_Returns_Not_Empty_Guid() { var storage = new SqlReminderStorage(_connectionString); Guid actual = storage.Add(new Core.ReminderItemRestricted { ContactId = "TestContactId", Date = DateTimeOffset.Now.AddHours(1), Message = "Test Message", Status = Core.ReminderItemStatus.Awaiting }); Assert.AreNotEqual(Guid.Empty, actual); }
public void Method_Get_List_Reminders_By_Status1() { var storage = new SqlReminderStorage(_connectionString); int expectedCountFailed = 2; var actualItemFailed = storage.Get(ReminderItemStatus.Failed); Assert.AreEqual(expectedCountFailed, actualItemFailed.Count); }
public void Method_Bulk() { var storage = new SqlReminderStorage(_connectionString); var ids = new List <Guid>() { new Guid("00000000-0000-0000-0000-222222222222"), new Guid("00000000-0000-0000-0000-111111111111") }; storage.UpdateStatus(ids, ReminderItemStatus.Failed); var actual = storage.Get(ReminderItemStatus.Failed); Assert.IsTrue(actual.Select(x => x.Id).Contains(ids[0])); Assert.IsTrue(actual.Select(x => x.Id).Contains(ids[1])); }
public void UpdateStatus_Method_With_Status_Only_Returns_All_Reminders_With_Requested_Status() { var storage = new SqlReminderStorage(_connectionString); IEnumerable <Guid> selectedReminderIds = storage .Get(ReminderItemStatus.Awaiting) .Select(x => x.Id); storage.UpdateStatus(selectedReminderIds, ReminderItemStatus.Failed); var actual = storage.Get(ReminderItemStatus.Failed); Assert.IsNotNull(actual); Assert.AreEqual(5, actual.Count); }
public void Get_By_Id_Method_Returns_Not_Null_Item_With_Proper_Fields() { Guid expectedGuid = Guid.Parse("00000000-0000-0000-0000-111111111111"); DateTimeOffset expectedDate = DateTimeOffset.Parse("2020-01-01 00:00:00 +00:00"); string expectedContactId = "ContactId_1"; string expectedMessage = "Message_1"; ReminderItemStatus expectedStatus = ReminderItemStatus.Awaiting; var storage = new SqlReminderStorage(_connectionString); var actualItem = storage.Get(expectedGuid); Assert.IsNotNull(actualItem); Assert.AreEqual(expectedGuid, actualItem.Id); Assert.AreEqual(expectedContactId, actualItem.ContactId); Assert.AreEqual(expectedDate, actualItem.Date); Assert.AreEqual(expectedMessage, actualItem.Message); Assert.AreEqual(expectedStatus, actualItem.Status); }
public void Update_Method_By_Id_Finally_Update_Status() { var storage = new SqlReminderStorage(_connectionString); Guid id = Guid.Parse("00000000-0000-0000-0000-333333333333"); var reminderStatus = storage.Get(id).Status; var expectedStatus = ReminderItemStatus.Failed; Assert.AreNotSame(expectedStatus, reminderStatus); storage.UpdateStatus(id, expectedStatus); var actualReminderStatus = storage.Get(id).Status; Assert.AreEqual(expectedStatus, actualReminderStatus); }
public void Get_By_Status_Method_Returns_2_Reminders_And_Returns_The_Same() { var storage = new SqlReminderStorage(_connectionString); var actual = storage.Get(ReminderItemStatus.Ready); Assert.IsTrue(actual.Count == 2); var reminder = new ReminderItem { Id = Guid.Parse("00000000-0000-0000-0000-222222222222"), ContactId = "ContactId_2", Date = DateTimeOffset.Parse("2020-02-02 00:00:00 +00:00"), Message = "Message_2", Status = (ReminderItemStatus)1 }; Assert.IsNotNull(actual.Where(x => x.Id == reminder.Id)); }
public void UpdateStatus_Method_With_Ids_Collection_Updates_Corresponded_Items() { var storage = new SqlReminderStorage(_connectionString); var ids = new List <Guid> { new Guid("00000000-0000-0000-0000-111111111111"), new Guid("00000000-0000-0000-0000-222222222222"), new Guid("00000000-0000-0000-0000-333333333333") }; storage.UpdateStatus(ids, ReminderItemStatus.Failed); var actual = storage.Get(ReminderItemStatus.Failed); Assert.IsTrue(actual.Select(x => x.Id).Contains(ids[0])); Assert.IsTrue(actual.Select(x => x.Id).Contains(ids[1])); Assert.IsTrue(actual.Select(x => x.Id).Contains(ids[2])); }
static void Main(string[] args) { var storage = new SqlReminderStorage( @"Data Source=localhost\SQLEXPRESS;Initial Catalog=Reminder;Integrated Security=true;"); //test add Guid id = storage.Add( DateTimeOffset.Now.AddMinutes(1), "Test message", "012345", Core.ReminderItemStatus.Failed); Console.WriteLine(id); //test get(id) var reminderItem = storage.Get(id); Console.WriteLine(JsonConvert.SerializeObject(reminderItem)); //test get(status) storage.Add( DateTimeOffset.Now.AddMinutes(1), "Test message", "012345", Core.ReminderItemStatus.Failed); var list = storage.Get(ReminderItemStatus.Failed); Console.WriteLine(list.Count); list = storage.Get(ReminderItemStatus.Ready); //проверка на нулевую ссылку Console.WriteLine(list.Count); //test update storage.Update(id, ReminderItemStatus.Sent); list = storage.Get(ReminderItemStatus.Sent); Console.WriteLine(list.Count); Console.ReadKey(); }
public void Get_Method_With_Status_Only_Returns_All_Reminders_With_Requested_Status() { var storage = new SqlReminderStorage(_connectionString); List <ReminderItem> actual; actual = storage.Get(ReminderItemStatus.Awaiting); Assert.IsNotNull(actual); Assert.AreEqual(2, actual.Count); actual = storage.Get(ReminderItemStatus.Ready); Assert.IsNotNull(actual); Assert.AreEqual(1, actual.Count); actual = storage.Get(ReminderItemStatus.Sent); Assert.IsNotNull(actual); Assert.AreEqual(2, actual.Count); actual = storage.Get(ReminderItemStatus.Failed); Assert.IsNotNull(actual); Assert.AreEqual(3, actual.Count); }
public void UpdateStatus_Method_For_IDs_Collection_Updates_The_Status() { var storage = new SqlReminderStorage(_connectionString); List <Guid> expectedIds = new List <Guid>(); expectedIds.Add(new Guid("00000000-0000-0000-0000-111111111111")); expectedIds.Add(new Guid("00000000-0000-0000-0000-222222222222")); expectedIds.Add(new Guid("00000000-0000-0000-0000-333333333333")); storage.UpdateStatus(expectedIds, ReminderItemStatus.Failed); var actual = storage.Get(ReminderItemStatus.Failed); Assert.IsNotNull(actual); var actualIds = actual.Select(x => x.Id).ToList(); Assert.IsTrue(actualIds.Contains(expectedIds[0])); Assert.IsTrue(actualIds.Contains(expectedIds[1])); Assert.IsTrue(actualIds.Contains(expectedIds[2])); }
public void Get_By_Id_Method_Returns_Russian_Message_After_Adding() { DateTimeOffset expectedDate = DateTimeOffset.Parse("2020-01-01 00:00:00 +00:00"); string expectedContactId = "ContactId_1"; string expectedMessage = "Сообщение на русском языке :)"; ReminderItemStatus expectedStatus = ReminderItemStatus.Awaiting; var storage = new SqlReminderStorage(_connectionString); Guid justAddedReminderId = storage.Add(new ReminderItemRestricted { ContactId = expectedContactId, Date = expectedDate, Message = expectedMessage, Status = expectedStatus }); var actualItem = storage.Get(justAddedReminderId); Assert.IsNotNull(actualItem); Assert.AreEqual(justAddedReminderId, actualItem.Id); Assert.AreEqual(expectedContactId, actualItem.ContactId); Assert.AreEqual(expectedDate, actualItem.Date); Assert.AreEqual(expectedMessage, actualItem.Message); Assert.AreEqual(expectedStatus, actualItem.Status); }