public void FirstOrDefaultAsyncTests_Country()
        {
            // Arrange
            BusMessage         busMessage = new BusMessage();
            Func <Group, bool> func       = x => x.Id == busMessage.Id && x.GroupType == ObjectType.Country;
            object             dbCountry  = new object();

            IRepository repository = this.CreateSut(func, dbCountry);

            // Act
            object obj = repository.FirstOrDefaultAsync <Group>(func);

            //Assert
            Assert.AreEqual(obj, dbCountry);
        }
        public void FirstOrDefaultAsyncTests_Office()
        {
            // Arrange
            BusMessage busMessage = new BusMessage();
            Expression <Func <Group, bool> > expression = x => x.Id == busMessage.Id && x.GroupType == ObjectType.Office;
            object dbOffice = new object();

            IRepository repository = this.CreateSut(expression, dbOffice);

            // Act
            object obj = repository.FirstOrDefaultAsync <Group>(expression);

            //Assert
            Assert.AreEqual(obj, dbOffice);
        }
Ejemplo n.º 3
0
        public void FirstOrDefaultAsyncTests()
        {
            // Arrange
            BusMessage         busMessage = new BusMessage();
            object             dbOffice   = new object();
            object             dbCountry  = new object();
            Func <Group, bool> d1         = x => x.Id == busMessage.Id && x.GroupType == ObjectType.Office;
            Func <Group, bool> d2         = x => x.Id == busMessage.Id && x.GroupType == ObjectType.Country;

            IRepository repository = A.Fake <IRepository>();

            A.CallTo(() => repository.FirstOrDefaultAsync <Group>(d1)).Returns(dbOffice);
            A.CallTo(() => repository.FirstOrDefaultAsync <Group>(d2)).Returns(dbCountry);

            // Act
            object obj1 = repository.FirstOrDefaultAsync <Group>(d1);
            object obj2 = repository.FirstOrDefaultAsync <Group>(d2);

            //Assert
            Assert.AreEqual(obj1, dbOffice);
            Assert.AreEqual(obj2, dbCountry);
        }