public void CreatePet_Should_Throw_ArgumentException_When_Pet_Exists()
        {
            // Arrange
            var users         = new Mock <IUserRepository>();
            var petRepository = new PetRepository(users.Object);
            var pet           = new Mock <IPet>();

            petRepository.CreatePet("", pet.Object);

            // Act & Assert
            Assert.ThrowsException <ArgumentException>(() => petRepository.CreatePet("", pet.Object));
        }
Beispiel #2
0
        private void CreatePet()
        {
            Console.Write("get the name: ");
            string name = Console.ReadLine();

            Console.Write("specify the type: ");
            string type = Console.ReadLine();

            Console.Write("get the birthday: ");
            DateTime birthday = Convert.ToDateTime(Console.ReadLine());

            Console.Write("get the SoldDate: ");
            DateTime SoldDate = Convert.ToDateTime(Console.ReadLine());

            Console.Write("get the colour: ");
            string colour = Console.ReadLine();

            Console.Write("get the PreviousOwner: ");
            string PreviousOwner = Console.ReadLine();

            Console.Write("get the Price: ");
            double price = Convert.ToInt32(Console.ReadLine());

            petRepo.CreatePet(type, name, birthday, SoldDate, colour, PreviousOwner, price);
            Console.WriteLine("A Pet has been added to the database.");
        }
        public void CreatePet_Should_Throw_ArgumentNullException_When_Pet_Is_Null()
        {
            // Arrange
            var users         = new Mock <IUserRepository>();
            var petRepository = new PetRepository(users.Object);

            // Act & Assert
            Assert.ThrowsException <ArgumentNullException>(() => petRepository.CreatePet("", null));
        }
        public void CreatePet_Should_Add_Pet_To_PetList_Correctly()
        {
            // Arrange
            var users         = new Mock <IUserRepository>();
            var petRepository = new PetRepository(users.Object);
            var pet           = new Mock <IPet>();

            // Act
            petRepository.CreatePet("", pet.Object);

            // Assert
            Assert.IsTrue(petRepository.Pets.Count == 1);
            Assert.IsTrue(petRepository.Pets.Contains(pet.Object));
        }
        public void DeletePet_Should_Remove_Pet_From_PetList()
        {
            // Arrange
            var users         = new Mock <IUserRepository>();
            var petRepository = new PetRepository(users.Object);
            var pet           = new Mock <IPet>();

            // Act
            petRepository.CreatePet("", pet.Object);
            petRepository.DeletePet("", pet.Object);

            // Assert
            Assert.IsTrue(!petRepository.Pets.Contains(pet.Object));
        }
        public void GetById_Should_Return_Correct_Pet()
        {
            // Arrange
            var users         = new Mock <IUserRepository>();
            var petRepository = new PetRepository(users.Object);
            var pet           = new Mock <IPet>();

            pet.Setup(x => x.Id).Returns("some id");
            var expected = pet.Object;

            petRepository.CreatePet("", expected);

            // Act
            var actual = petRepository.GetById("some id");

            // Assert
            Assert.AreEqual(expected, actual);
        }