Пример #1
0
        public void TestCreateTenant()
        {
            // Arrange
            var ms = new MarketplaceService();
            var c  = new ManagedCustomer
            {
                Email     = "*****@*****.**",
                FirstName = "Foo",
                LastName  = "Bar"
            };

            c.Save();

            Action f1 = () => ms.CreateTenant(null);

            f1.ShouldThrow <ArgumentNullException>().WithMessage("Value cannot be null.\r\nParameter name: customer");

            // Act
            var t = ms.CreateTenant(c);

            // Assert
            t.Should().NotBeNull();
            t.Customer.Should().NotBeNull();
            t.Customer.Id.Should().Be(c.Id);
            t.IsTemporaryId.Should().BeTrue();
            t.Name.Should().Be("FOOBARCOM");

            // The means for determining the tenant name... not 100% solid yet.
            c.Name = "Foo Bar";
            t      = ms.CreateTenant(c);
            t.Name.Should().Be("FOOBAR");

            c.Company = "Elbow Inc.";
            t         = ms.CreateTenant(c);
            t.Name.Should().Be("ELBOWINC");

            // If the tenant name already exists?... not 100% solid yet.
            t.Save();
            t = ms.CreateTenant(c);
            t.Name.Should().NotBe("ELBOWINC");
            t.Name.Should().StartWith("ELBOWINC_");
        }