示例#1
0
 public void CreateBook(string author, string title, string day, string mounts, string year)
 {
     valid.ValidateBook(author, title, day, mounts, year);
     repo.Create(new Book {
         Author = author, Title = title, EditionDate = DateTimeOffset.Parse($"{day}/{mounts}/{year}")
     });
 }
示例#2
0
        public void Validate_Empty_Title()
        {
            var mockSet = new Mock <DbSet <Book> >();

            mockSet.As <IQueryable <Book> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <Book> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Book> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Book> >().Setup(m => m.GetEnumerator()).Returns(() => data.GetEnumerator());

            var mockContext = new Mock <ApplicationContext>();

            mockContext.Setup(c => c.Books).Returns(mockSet.Object);

            var validateBook = new IsValid(mockContext.Object);

            validateBook.ValidateBook("Author", "", "01", "12", "1996");
        }
示例#3
0
        public void Validate_NonNumeric_Year()//Field mounths contain non-numeric elements
        {
            var mockSet = new Mock <DbSet <Book> >();

            mockSet.As <IQueryable <Book> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <Book> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Book> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Book> >().Setup(m => m.GetEnumerator()).Returns(() => data.GetEnumerator());

            var mockContext = new Mock <ApplicationContext>();

            mockContext.Setup(c => c.Books).Returns(mockSet.Object);

            var validateBook = new IsValid(mockContext.Object);

            validateBook.ValidateBook("Author", "Title", "01", "12", "1996* ///");
        }