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); }
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(); }
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); }
public async Task World_can_add_new_realm() { // 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); // Assert Assert.AreEqual(1, world.GetRealmsInWorld().Count()); }