Esempio n. 1
0
        public async Task Adding_realm_sets_its_enabled_flag()
        {
            // Arrange
            IRealmFactory factory = Mock.Of<IRealmFactory>(mock => 
            mock.CreateRealm(It.IsAny<string>(), It.IsAny<IWorld>()) == Task.FromResult(
                    Mock.Of<IRealm>(r => r.Name == "Unit Test" && r.IsEnabled == true)));

            var world = new MudWorld(factory);
            var realmName = "Test Realm";
            IRealm realm = await world.CreateRealm(realmName);

            // Act
            await world.AddRealmToWorld(realm);

            // Assert
            Assert.IsTrue(realm.IsEnabled);
        }
Esempio n. 2
0
        public async Task Adding_realm_to_world_without_a_name_throws_exception()
        {
            // Arrange
            IRealmFactory factory = Mock.Of<IRealmFactory>(
                mock => mock.CreateRealm(It.IsAny<string>(), It.IsAny<IWorld>()) == Task.FromResult(Mock.Of<IRealm>()));

            var world = new MudWorld(factory);
            var realmName = "Test Realm";
            IRealm realm = await world.CreateRealm(realmName);

            // Act
            await world.AddRealmToWorld(realm);

            // Assert
            Assert.Fail();
        }
Esempio n. 3
0
        public async Task World_does_not_add_same_realm_twice()
        {
            // Arrange
            IRealmFactory factory = Mock.Of<IRealmFactory>(
                mock => mock.CreateRealm(It.IsAny<string>(), It.IsAny<IWorld>()) == Task.FromResult(
                    Mock.Of<IRealm>(r => r.Name == "Unit Test")));

            var world = new MudWorld(factory);
            var realmName = "Test Realm";
            IRealm realm = await world.CreateRealm(realmName);

            // Act
            await world.AddRealmToWorld(realm);
            await world.AddRealmToWorld(realm);

            // Assert
            Assert.AreEqual(1, world.GetRealmsInWorld().Count());
        }
Esempio n. 4
0
        public async Task World_can_create_a_realm()
        {
            // Arrange
            IRealmFactory factory = Mock.Of<IRealmFactory>(
                mock => mock.CreateRealm(It.IsAny<string>(), It.IsAny<IWorld>()) == Task.FromResult(Mock.Of<IRealm>()));

            var world = new MudWorld(factory);
            var realmName = "Test Realm";

            // Act
            IRealm realm = await world.CreateRealm(realmName);

            // Assert
            Assert.IsNotNull(realm);
        }