Create() public method

public Create ( Entry entry ) : void
entry Entry
return void
コード例 #1
0
		public void CanSaveAndReadEntry()
		{
			var phoneBook = new PersistentPhoneBook(new MemoryStream());

			var expected = new Entry
			{
				FirstName = "ayende",
				LastName = "rahien",
				Number = "01231412312312",
				Type = "Home"
			};
			phoneBook.Create(expected);

			var actual = phoneBook.ReadEntries().First();

			Assert.Equal(expected, actual);
		}
コード例 #2
0
		public void CanReadMultipleValues()
		{
			var phoneBook = new PersistentPhoneBook(new MemoryStream());

			for (int i = 0; i < 5; i++)
			{
				var expected = new Entry
				{
					FirstName = "ayende",
					LastName = "rahien",
					Number = "01231412312312",
					Type = "Home"
				};
				phoneBook.Create(expected);
			}

			Assert.Equal(5, phoneBook.ReadEntries().Count());
		}
コード例 #3
0
		public void CanCreateAndEndEntry()
		{
			var phoneBook = new PersistentPhoneBook(new MemoryStream());

			var expected = new Entry
			{
				FirstName = "ayende",
				LastName = "rahien",
				Number = "01231412312312",
				Type = "Home"
			};
			phoneBook.Create(expected);

			var fromPhoneBook = phoneBook.ReadEntries().First();

			fromPhoneBook.LastName = "eini";
			fromPhoneBook.FirstName = "oren";

			phoneBook.Edit(fromPhoneBook);

			var fromPhoneBook2 = phoneBook.ReadEntries().First();

			Assert.Equal(fromPhoneBook, fromPhoneBook2);
		}
コード例 #4
0
		public void OnDisposeWillCompact()
		{
			var memoryStream = new MemoryStream();
			var phoneBook = new PersistentPhoneBook(memoryStream, streamOwner:false);

			for (int i = 0; i < 5; i++)
			{
				var expected = new Entry
				{
					FirstName = "ayende",
					LastName = "rahien",
					Number = "01231412312312",
					Type = "Home"
				};
				phoneBook.Create(expected);
			}

			var before = memoryStream.Length;

			var entry = phoneBook.ReadEntries()
				.Skip(2).First();
			phoneBook.Delete(entry);

			Assert.Equal(before, memoryStream.Length); // shouldn't change

			phoneBook.Dispose();

			Assert.True(before > memoryStream.Length);

		}
コード例 #5
0
		public void CanDeleteEntry()
		{
			var phoneBook = new PersistentPhoneBook(new MemoryStream());

			for (int i = 0; i < 5; i++)
			{
				var expected = new Entry
				{
					FirstName = "ayende",
					LastName = "rahien",
					Number = "01231412312312",
					Type = "Home"
				};
				phoneBook.Create(expected);
			}

			var entry = phoneBook.ReadEntries()
				.Skip(2).First();
			phoneBook.Delete(entry);

			Assert.Equal(4, phoneBook.ReadEntries().Count());
		}