示例#1
0
        public async Task Part_Repository_Should_Get_All_Async()
        {
            // Arrange
            var context        = TestSetUpHelper.CreateDbContext();
            var repository     = new PartRepository(context);
            var expectedEntity = new Part()
            {
                Id     = 4,
                Name   = "TestName",
                Code   = "123456",
                UnitId = 1,
                Unit   = new Unit {
                    Id = 1, Name = "Kilo", ShortName = "kg",
                },
                ManufacturerId = 1,
                Manufacturer   = new Manufacturer {
                    Id = 1, Name = "",
                }
            };

            await repository.AddAsync(expectedEntity);

            await context.SaveChangesAsync();

            // Act
            var entities = await repository.GetAllAsync();

            // Assert
            Assert.Single(entities.ToList());
        }