コード例 #1
0
        public void Given_Group_When_NewGroupIsAdded_Then_ShouldHaveOneGroupInDatabase()
        {
            RunOnDatabase(context => {
                // ARRANGE


                context.Roles.Add(Role.Create("student"));
                context.SaveChanges();

                var userType = context.Roles.FirstOrDefault();
                if (userType != null)
                {
                    var user = User.Create(
                        "User first name",
                        "User last name",
                        "User",
                        "*****@*****.**",
                        "parola"
                        );
                    context.Users.Add(user);
                }
                context.SaveChanges();

                var userId = context.Users.FirstOrDefault();

                var groupRepository = new GroupsRepository(context);
                if (userId == null)
                {
                    return;
                }
                var group = Group.Create(

                    "A2",
                    "grupa din anul III",
                    userId.Id

                    );
                var groupInserted = groupRepository.InsertAsync(@group).Result;
                // ACT
                var result = groupRepository.GetByIdAsync(groupInserted.Id);
                // ASSERT
                result.Should().NotBe(null);
            });
        }